Re: How to transfer "2.2864849511949E+190" to a normal-human-readable number?
| From: | Ben Peter | Date: | Fri, 16 Feb 2001 11:33:26 +0000 |
| Subject: | Re: How to transfer "2.2864849511949E+190" to a normal-human-readable number? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-40134@lists.php.net to get a copy of this message | ||
Hi,
have to correct that (thanks to Adam Whitehead for pointing out).
It should be %f instead of %d. However:
'<? $foo = 2.2864849511949E+190; settype($foo,"double"); printf("%f\n",
$foo) ?>' | php -q
2286484951194899000000000000000000000000000000000000000000000000000000000000000
Segmentation fault (core dumped)
[ben@home ben]$
This is PHP4.0.4pl1
Ben
Ben Peter wrote:
>
> Hi,
>
> I tried
>
> <? $foo = 2.2864849511949E+190; settype($foo,"double"); printf("%d\n",
> $foo) ?>
>
> which gave me
>
> -2147483648
>
> echo $foo gives
>
> 2.2864849511949E+190
>
> - This looks like the number is too large for printf (the 'human
> readable form' printed by printf is abviously wrong).
>
> Does anybody know such of limits to sprintf?
>
> Ben
>
> SED wrote:
> >
> > Hi,
> >
> > I'm multiplying floating numbers:
> >
> > $result = $foo * $boo; and the result is like this:
> >
> > echo "$result";
> >
> > And the result is like this:
> >
> > 2.2864849511949E+190
> >
> > How can I transfer this to normal-human-readable number?
> >
> > Regards,
> > Sumarlidi Einar Dadason
> >
> > SED - Graphic Design
> >
> > ------------------------------------------
> > Phone: (+354) 4615501
> > Mobile: (+354) 8960376
> > Fax: (+354) 4615503
> > E-mail: sed@sed.is
> > Homepage: www.sed.is <- New Homepage!
> > ------------------------------------------
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net