Jump to content

[SOLVED] divide numbers strange results


phpnewbie112

Recommended Posts

Hello,

 

I have the following piece of code:

 

$out = "1.1";

$rate = "1.1";

$after =  $out/$rate;

print $after;  //Result is showing 1 normally

 

the problem is with the following wrong result

 

$a = "1";

$cnt = "1";

$b = (($out/$rate) - ($cnt * $a));

print $b;

 

the result is supposed to be 0 but I am having as a result:

1.11022302463E-15

 

very wierd!!!

Link to comment
https://forums.phpfreaks.com/topic/130086-solved-divide-numbers-strange-results/
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.