Skip to main content
deleted 1 characters in body
Source Link
apscience
  • 7.3k
  • 11
  • 58
  • 91

I am trying to round the double 0.0045. When I call...

echo round($theFloat, 3); 

I get 0.004, instead of 0.005 which is the expected response.

Here is the code:

$increase = 1.1; $previousPrice = round(0.11 / $increase, 2); $nextPrice = round(0.11 * $increase, 2); $afterCut = round($r[1]0.11 * 0.95, 6); $willSend = $afterCut - $previousPrice; echo round($willSend, 3); 

I am trying to round the double 0.0045. When I call...

echo round($theFloat, 3); 

I get 0.004, instead of 0.005 which is the expected response.

Here is the code:

$increase = 1.1; $previousPrice = round(0.11 / $increase, 2); $nextPrice = round(0.11 * $increase, 2); $afterCut = round($r[1] * 0.95, 6); $willSend = $afterCut - $previousPrice; echo round($willSend, 3); 

I am trying to round the double 0.0045. When I call...

echo round($theFloat, 3); 

I get 0.004, instead of 0.005 which is the expected response.

Here is the code:

$increase = 1.1; $previousPrice = round(0.11 / $increase, 2); $nextPrice = round(0.11 * $increase, 2); $afterCut = round(0.11 * 0.95, 6); $willSend = $afterCut - $previousPrice; echo round($willSend, 3); 
Source Link
apscience
  • 7.3k
  • 11
  • 58
  • 91

PHP not rounding floats properly?

I am trying to round the double 0.0045. When I call...

echo round($theFloat, 3); 

I get 0.004, instead of 0.005 which is the expected response.

Here is the code:

$increase = 1.1; $previousPrice = round(0.11 / $increase, 2); $nextPrice = round(0.11 * $increase, 2); $afterCut = round($r[1] * 0.95, 6); $willSend = $afterCut - $previousPrice; echo round($willSend, 3);