Re: How to transfer "2.2864849511949E+190" to a normal-human-readable number?

From: Date: Fri, 16 Feb 2001 16:31:25 +0000
Subject: Re: How to transfer "2.2864849511949E+190" to a normal-human-readable number?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-40168@lists.php.net to get a copy of this message
On Friday 16 February 2001 12:33, Ben Peter wrote: > It should be %f instead of %d. However: > > '<? $foo = 2.2864849511949E+190; settype($foo,"double"); > printf("%f\n", > $foo) ?>' | php -q > 22864849511948990000000000000000000000000000000000000000000000000000000 >00000000 Segmentation fault (core dumped) Well, I *can* understand that printf () isn't prepared to handle numbers with 190 digits :) > > > 2.2864849511949E+190 > > > > > > How can I transfer this to normal-human-readable number? Well, I doubt that 2286484951194899000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 is more human-readable than 2.2864849511949E+190 Perhaps you want to change it to 2.2864849511949 * 10^190 But I'd say adding a note explaining the "E" notation is simpler... PS: The long number is, scientifically seen, also *less* correct than the 'E' form - the 'E' form states that it is a number with a precision of 16 digits, while the long one implies that it has a precision of 190 digits (which is definitely wrong). -- Christian Reiniger LGDC Webmaster (http://sunsite.dk/lgdc/) "World domination. Fast." (Linus Torvalds about Linux)

« previous php.general (#40168) next »