Hello List.
In an earlier post, I received help with a custom function to round
decimals off (the custom function provided by Adam Richardson is below).
However in my MySQL db, when I have values with only 1 decimal point,
I need the value PHP returns to display as 2. For example, 3.8
Hello List.
In an earlier post, I received help with a custom function to round
decimals off (the custom function provided by Adam Richardson is
below).
However in my MySQL db, when I have values with only 1 decimal
point, I need the value PHP returns to display as 2. For example,
3.8
On Jan 22, 2010, at 4:24 PM, tedd wrote:
Hello List.
In an earlier post, I received help with a custom function to round
decimals off (the custom function provided by Adam Richardson is
below).
However in my MySQL db, when I have values with only 1 decimal
point, I need the value PHP
Paul M Foster wrote:
On Mon, Jan 11, 2010 at 04:56:03PM -0500, tedd wrote:
--Rick:
The above described rounding algorithm introduces more bias than
simply using PHP's round() function, which always rounds down. IMO,
modifying rounding is not worth the effort.
The best rounding algorithm
Rick Dwyer wrote:
On Jan 22, 2010, at 4:24 PM, tedd wrote:
Hello List.
In an earlier post, I received help with a custom function to round
decimals off (the custom function provided by Adam Richardson is below).
However in my MySQL db, when I have values with only 1 decimal point,
I
On Jan 22, 2010, at 7:30 PM, Nathan Rixham wrote:
Thanks Nathan I'll give it a shot.
--Rick
your doing the number format before the rounding.. here's a version of
the function that should fit the bill:
function round_to_half_cent( $value )
{
$value *= 100;
if( $value
Rick Dwyer wrote:
On Jan 22, 2010, at 7:30 PM, Nathan Rixham wrote:
Thanks Nathan I'll give it a shot.
np - here's a more condensed version:
function round_to_half_cent( $value )
{
$value = ($value*100) + 0.3;
$out = number_format( floor($value)/100 , 2 );
return $out
Thank you Nathan,
This worked quite well.
--Rick
On Jan 22, 2010, at 8:10 PM, Nathan Rixham wrote:
Rick Dwyer wrote:
On Jan 22, 2010, at 7:30 PM, Nathan Rixham wrote:
Thanks Nathan I'll give it a shot.
np - here's a more condensed version:
function round_to_half_cent( $value )
{
$newprice = sprintf($%.2f, 15.109);
On Sun, Jan 10, 2010 at 8:36 PM, Rick Dwyer rpdw...@earthlink.net wrote:
Hello List.
Probably an easy question, but I am not able to format a number to round up
from 3 numbers after the decimal to just 2.
My code looks like this:
$newprice =
I have been asked to further modify the value to the nearest half cent.
So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5. And if it 7, 8 or 9 it
gets rounded up to full cents.
Can this be done fairly easily? Not knowing PHP
On Mon, Jan 11, 2010 at 02:55:33PM -0500, Rick Dwyer wrote:
I have been asked to further modify the value to the nearest half cent.
So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5. And if it 7, 8 or 9 it
gets rounded up to
At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:
I have been asked to further modify the value to the nearest half cent.
So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5. And if it 7, 8 or 9
it gets rounded up to full cents.
Can
On Jan 11, 2010, at 4:56 PM, tedd wrote:
At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:
I have been asked to further modify the value to the nearest half
cent.
So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5. And if it 7, 8
tedd wrote:
At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:
I have been asked to further modify the value to the nearest half cent.
So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in 3, 4, 5, 6 it gets rounded to 5. And if it 7, 8 or 9
it gets rounded up to full
On Mon, Jan 11, 2010 at 7:45 PM, Mattias Thorslund matt...@thorslund.uswrote:
tedd wrote:
At 2:55 PM -0500 1/11/10, Rick Dwyer wrote:
I have been asked to further modify the value to the nearest half cent.
So if the 3rd decimal spot ends in 1 or 2, it gets rounded down to 0
If it ends in
On Mon, Jan 11, 2010 at 04:56:03PM -0500, tedd wrote:
--Rick:
The above described rounding algorithm introduces more bias than
simply using PHP's round() function, which always rounds down. IMO,
modifying rounding is not worth the effort.
The best rounding algorithm is to look at the last
Hello List.
Probably an easy question, but I am not able to format a number to
round up from 3 numbers after the decimal to just 2.
My code looks like this:
$newprice = $.number_format($old_price, 2, ., ,);
and this returns $0.109 when I am looking for $0.11.
I tried:
$newprice =
Testing this out a little:
matt...@mumin:~$ php -r 'echo \$.number_format(0.109, 2, ., ,).\n;'
$0.11
matt...@mumin:~$ php -r 'echo $.number_format(0.109, 2, ., ,).\n;'
$0.11
matt...@mumin:~$ php -r 'echo $.number_format(0.109, 2, .,
,).\n;'
$0.11
I think the $ should be escaped with a
18 matches
Mail list logo