Richard's right. You get the same result if you do the equivalent in
ASP.
Regards,
Bruce
>>> "Richard Lynch" <[EMAIL PROTECTED]> 8/08/2007 3:29:16 p.m. >>>
On Wed, August 1, 2007 11:52 am, Mark Summers wrote:
> This sort of thing really isn't helpful...
>
>
> $a = 75.82 * 100;
>
> echo intval
On Wed, August 1, 2007 11:52 am, Mark Summers wrote:
> This sort of thing really isn't helpful...
>
>
> $a = 75.82 * 100;
>
> echo intval($a);
>
> ?>
What did you get?
What did you expect?
Do you have ANY idea how floats are actually represented internally in
every computer language? [*]
If you
Those numbers must fall on the other side of the number. E.g.,
75.81 ==> 75.8100011 (etc)
so you get the expected results.
Mark Summers wrote:
> I like to think that I'm reasonably aware of the limitations of floating
> point (famous last words).
>
> To my mind, the ridiculousness (probab
I like to think that I'm reasonably aware of the limitations of floating
point (famous last words).
To my mind, the ridiculousness (probably not a word) of the example is
highlighted by the fact that 75.81 and 75.83 work perfectly.
Roberto Mansfield wrote:
Internally, 75.82 can't be stored e
Roberto Mansfield wrote:
Internally, 75.82 can't be stored exactly, so 75.82 * 100 is probably
7581.92 rather than the expected integer value of 7582. So intval is
behaving properly. Sounds like you want intval(round($a));
[EMAIL PROTECTED] wrote:
Very weird and counter intuitive. Lookin
On 8/1/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Probably return "7582" instead of "7581".
>
> = = = Original message = = =
>
> On 8/1/07, Mark Summers <[EMAIL PROTECTED]> wrote:
> > This sort of thing really isn't helpful...
> >
> > >
> > $a = 75.82 * 100;
> >
> > echo intval($a);
> >
>
Internally, 75.82 can't be stored exactly, so 75.82 * 100 is probably
7581.92 rather than the expected integer value of 7582. So intval is
behaving properly. Sounds like you want intval(round($a));
[EMAIL PROTECTED] wrote:
> Very weird and counter intuitive. Looking at the php manual, I see
It is most definitely not if what you want is the square root, or the
hyperbolic cosine or any other of a zillion things.
- Original Message -
From: "Mark Summers" <[EMAIL PROTECTED]>
To:
Sent: Wednesday, August 01, 2007 6:52 PM
Subject: [PHP] Loss of precision in
Probably return "7582" instead of "7581".
= = = Original message = = =
On 8/1/07, Mark Summers <[EMAIL PROTECTED]> wrote:
> This sort of thing really isn't helpful...
>
>
> $a = 75.82 * 100;
>
> echo intval($a);
>
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, vis
Very weird and counter intuitive. Looking at the php manual, I see this:
Converting to integer from floating point:
"When converting from float to integer, the number will be rounded towards
zero."
But you'd think the multiplication would happen before the rounding.
if you do:
$a = ceil(75.82
On 8/1/07, Mark Summers <[EMAIL PROTECTED]> wrote:
> This sort of thing really isn't helpful...
>
>
> $a = 75.82 * 100;
>
> echo intval($a);
>
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
What exactly were you expecting it t
This sort of thing really isn't helpful...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
12 matches
Mail list logo