RE: [PHP] Changing numbers
> From: Brad Pauly [mailto:[EMAIL PROTECTED] > Sent: Monday, July 21, 2003 2:45 PM > To: Roger B.A Klorese > Cc: 'justin gruenberg'; 'Curt Zirzow'; 'PHP-General' > Subject: Re: [PHP] Changing numbers > > > I am not sure what he is after, but I don't think it has to do with > significant figures (if that is what you meant). If that was > the case, > 12.400 should remain 12.400. Trailing zeros to the right of a decimal > are significant. Perhaps. But he's saying that, for his purposes, they're not -- if anything to the right of the last shown zero existed, it would be reflected in the output. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Changing numbers
Roger B.A Klorese wrote: * Thus wrote zavaboy ([EMAIL PROTECTED]): I have the following numbers: 12.400 666.75 23 369.2 3.234 How can I make them have at least 2 decimal places? So, they will output: 12.40 666.75 23.00 269.20 3.234 What's so hard about this? He wants two or more *significant* positions preserved. Show to at least two decimal places, trailing zeroes truncated beyond the 2nd decimal place. I am not sure what he is after, but I don't think it has to do with significant figures (if that is what you meant). If that was the case, 12.400 should remain 12.400. Trailing zeros to the right of a decimal are significant. - Brad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Changing numbers
> From: justin gruenberg [mailto:[EMAIL PROTECTED] > Subject: Re: [PHP] Changing numbers > > > Curt Zirzow wrote: > > >* Thus wrote zavaboy ([EMAIL PROTECTED]): > > > > > >>I have the following numbers: > >> > >>12.400 > >>666.75 > >>23 > >>369.2 > >>3.234 > >> > >>How can I make them have at least 2 decimal places? > >>So, they will output: > >> > >>12.40 > >>666.75 > >>23.00 > >>269.20 > >>3.234 > >> > >>Thanks in advance! > >> > > What I dont understand is that your examples are not consitant. You > want 2 or more decimal positions, so as if there are more than 2, to > leave what exists. But your first example, you truncate the > last 0. Is > that a typo, or intentional? What's so hard about this? He wants two or more *significant* positions preserved. Show to at least two decimal places, trailing zeroes truncated beyond the 2nd decimal place. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Changing numbers
Curt Zirzow wrote: * Thus wrote zavaboy ([EMAIL PROTECTED]): I have the following numbers: 12.400 666.75 23 369.2 3.234 How can I make them have at least 2 decimal places? So, they will output: 12.40 666.75 23.00 269.20 3.234 Thanks in advance! What I dont understand is that your examples are not consitant. You want 2 or more decimal positions, so as if there are more than 2, to leave what exists. But your first example, you truncate the last 0. Is that a typo, or intentional? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Changing numbers
* Thus wrote zavaboy ([EMAIL PROTECTED]): > I have the following numbers: > > 12.400 > 666.75 > 23 > 369.2 > 3.234 > > How can I make them have at least 2 decimal places? > So, they will output: > > 12.40 > 666.75 > 23.00 > 269.20 > 3.234 > > Thanks in advance! http://php.net/number_format or http://php.net/printf Curt -- "I used to think I was indecisive, but now I'm not so sure." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Changing numbers
bob parker wrote: On Tue, 22 Jul 2003 04:03, zavaboy wrote: *Sigh*, lets say I have: 2.65 3.3 5.2670 12.030 I would like it at least 2 decimal places.. So, 5.2670 would be 5.267 not 5.27: 5.267 is 3 decimal places - count them He said "at least 2 decimal places", not "exactally two decimal places". -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Changing numbers
On Tue, 22 Jul 2003 04:03, zavaboy wrote: > *Sigh*, lets say I have: > > 2.65 > 3.3 > 5.2670 > 12.030 > > I would like it at least 2 decimal places.. So, 5.2670 would be 5.267 not > 5.27: > 5.267 is 3 decimal places - count them -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Changing numbers
zavaboy wrote: *Sigh*, lets say I have: 2.65 3.3 5.2670 12.030 I would like it at least 2 decimal places.. So, 5.2670 would be 5.267 not 5.27: 2.65 3.30 5.267 12.03 "James Rodenkirch" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] try rounding it first http://www.php.net/manual/en/function.round.php Zavaboy wrote: What about if I had 2.856 that function will make it 2.86. "Jay Blanchard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [snip] How can I make them have at least 2 decimal places? [/snip] RTFM at http://www.php.net/number_format HTH! *Sigh* RTFM - http://us4.php.net/sprintf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Changing numbers
[snip] I would like it at least 2 decimal places.. So, 5.2670 would be 5.267 not 5.27: [/snip] RTFM for formatted string http://us3.php.net/sprintf or http://us3.php.net/printf HTH -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Changing numbers
*Sigh*, lets say I have: 2.65 3.3 5.2670 12.030 I would like it at least 2 decimal places.. So, 5.2670 would be 5.267 not 5.27: 2.65 3.30 5.267 12.03 "James Rodenkirch" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > try rounding it first > > http://www.php.net/manual/en/function.round.php > > Zavaboy wrote: > > > What about if I had 2.856 that function will make it 2.86. > > > > > > "Jay Blanchard" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > [snip] > > How can I make them have at least 2 decimal places? > > [/snip] > > > > RTFM at http://www.php.net/number_format > > > > HTH! > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Changing numbers
try rounding it first http://www.php.net/manual/en/function.round.php Zavaboy wrote: What about if I had 2.856 that function will make it 2.86. "Jay Blanchard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [snip] How can I make them have at least 2 decimal places? [/snip] RTFM at http://www.php.net/number_format HTH! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Changing numbers
What about if I had 2.856 that function will make it 2.86. "Jay Blanchard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [snip] How can I make them have at least 2 decimal places? [/snip] RTFM at http://www.php.net/number_format HTH! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Changing numbers
[snip] How can I make them have at least 2 decimal places? [/snip] RTFM at http://www.php.net/number_format HTH! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php