Re: [PHP] Help. Floats turning into really small numbers? x.xxxxxxxxxxxxxxxxxxxxxxE-xx- Narrowed it down!

2005-04-05 Thread Satyam
What you see as round numbers in base 10, are not so in binary. Numbers such as .5, .25, .125, .0625 and so on, multiples of one half, are round numbers in binary, though they don't look so in decimal. Others which look pretty simple in decimal are not, for example, 0.1 gives you an infinite

Re: [PHP] Help. Floats turning into really small numbers? x.xxxxxxxxxxxxxxxxxxxxxxE-xx - Narrowed it down!

2005-04-04 Thread Anthony Tippett
Ok i've narrowed it down a little bit but still can't figure it out.. Here's the code and what I get for the output. Does anyone know what's going on? Can someone else run it on their computer and see if they get the same results? ?php $a = 17.00 * 1; $a+= 1.10 * 1; $a+= 0.32 * 1; $a+= 0.07 *

Re: [PHP] Help. Floats turning into really small numbers? x.xxxxxxxxxxxxxxxxxxxxxxE-xx - Narrowed it down!

2005-04-04 Thread Richard Lynch
Floats are NEVER going to be coming out even reliably. You'll have to check if the difference is less than X for whatever number X you like. Or you can look at something like BC_MATH where precision can be carried out as far as you like... But what you are seeing is to be expected. That's just

Re: [PHP] Help. Floats turning into really small numbers? x.xxxxxxxxxxxxxxxxxxxxxxE-xx - Narrowed it down!

2005-04-04 Thread Anthony Tippett
btw, thanks for your response. I'm not sure as if I understand why. It's not like I'm using a very precise number when dealing with the hundreths place. Even without the multiplication the number gets messed up. eg. $a = 17.00; $a+= 1.10; $a+= 0.32; $a+= 0.07; print $a.br; // 18.49

Re: [PHP] Help. Floats turning into really small numbers? x.xxxxxxxxxxxxxxxxxxxxxxE-xx - Narrowed it down!

2005-04-04 Thread Anthony Tippett
Thanks to everyone that helped. After further googling, bug 9288 had a good explanation of what was going on ( which is not a bug) http://bugs.php.net/bug.php?id=9288edit=3 I'll just include the answer for anyone that comes upon this tread on a search engine. [15 Feb 2001 2:55pm CET] hholzgra