mudshark79
Member
While doing some improvements on one of my Fabrik-Applications and banging my head for maybe 5 hours I found out out a lot of interesting things about floating-point-Numbers in general but also that even the most simple math goes wrong from time to time?
It basically breaks down to this:
On some Ubuntu-Host of mine, PHP 5.5.9
echo var_dump((int)230918/(int)100);
gives
float(2309.18) test
On a shared hoster with PHP 5.4.39 this:
echo var_dump((int)230918/(int)100);
gives
float(2309.1799999999998363)
Now I understand that there may be no proper representation for certain floating-point numbers but 2309.18 isn't one of these, ain't it? But even more important, this only shows on one server and not on the other? Is there some switch in the config? Why are some those simple things so hard sometimes?
Comments appreciated ,
Regards,
Matthias
It basically breaks down to this:
On some Ubuntu-Host of mine, PHP 5.5.9
echo var_dump((int)230918/(int)100);
gives
float(2309.18) test
On a shared hoster with PHP 5.4.39 this:
echo var_dump((int)230918/(int)100);
gives
float(2309.1799999999998363)
Now I understand that there may be no proper representation for certain floating-point numbers but 2309.18 isn't one of these, ain't it? But even more important, this only shows on one server and not on the other? Is there some switch in the config? Why are some those simple things so hard sometimes?
Comments appreciated ,
Regards,
Matthias
Last edited: