0

this is a part of my code.I'd like get int value 2040 but the int value is 2039.

$double = 100 * '20.40';
$int = (int)$double;
echo gettype($double)."=$double\n"; //output 2040
echo gettype($int)."=$int\n";      //output 2039
yivi
  • 42,438
  • 18
  • 116
  • 138
mht SLS
  • 19
  • 3

1 Answers1

-1
$double = 100 * 20.40;
$int = (int)round($double);

echo gettype($double)."=$double\n"; //output double=2040 
echo gettype($int)."=$int\n"; //output integer=2040 
Vash72
  • 604
  • 5
  • 13