Jump to content

abnormal behavior of php code!


reimei

Recommended Posts

Hello

I'm confused with the behavior of the following code:

$t = 9.8;
$deltaT = 0.1;
while($t < 10)
{
    $t = $t+ $deltaT;
    echo $t.'<br />';
}

For $t = 9.8, it echos the correct result(the last number it echos is 10), but for $t smaller than 9.8, for example $t = 9.5, the last number it echos is 10.1.

why?!

Link to comment
https://forums.phpfreaks.com/topic/283125-abnormal-behavior-of-php-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.