Re: string prints out as number (E+10...), why?

From: Date: Thu, 09 Jan 2003 09:35:47 +0000
Subject: Re: string prints out as number (E+10...), why?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-130895@lists.php.net to get a copy of this message
Jean-Christian Imbeault <jc@mega-bucks.co.jp> wrote: > - Edwin wrote: > > > > I guess it's because the number is converted automatically to an > > exponential notation if it goes over a certain number of digits--makes > > it easier to read... > > I figured as much. But why? I found a solution by changing the precision > of floats in the php.ini file. > > But I still find it strange that PHP will, internally, happily treat my > variable as a string but when it comes time to print it out, it decides > that it's a number and formats it without my asking it to. Mmm, I'm not sure if I understand this correctly but I don't think PHP will "just decide" that your string IS a number and *formats* it. Consider this: <?php $var = 1111111111111111; // int $var2 = "1111111111111111"; // str echo $var; // echoes 1.11111111111E+015 echo '<br />'; echo $var2; // echoes 1111111111111111 ?> As you can see, PHP didn't "touch" the string version... Anyway, I don't think the conversion to an exponential notation is peculiar to PHP--my math teacher required me to do the same :) - E __________________________________________________ Do You Yahoo!? Yahoo! BB is Broadband by Yahoo! http://bb.yahoo.co.jp/

« previous php.general (#130895) next »