raphael75 Posted May 1, 2014 Share Posted May 1, 2014 So I have 2 arrays of numbers, and this:$variance = array_sum($db_tot) - array_sum($cr_tot);If the sum of each array is the same, why does PHP return -1.8189894035459E-12? Why wouldn't it be 0 (positive 0 or just 0)?Thanks! Link to comment https://forums.phpfreaks.com/topic/288158-negative-zero/ Share on other sites More sharing options...
raphael75 Posted May 1, 2014 Author Share Posted May 1, 2014 Figured it out - floating point math isn't straightforward. Had to use number_format to round to 2 decimal places. Link to comment https://forums.phpfreaks.com/topic/288158-negative-zero/#findComment-1477821 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.