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 )
{
$
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 $o
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 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
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" ro
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 r
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 need
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 need
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
On Mon, Jan 11, 2010 at 7:45 PM, Mattias Thorslund wrote:
> 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,
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 ce
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 or
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 th
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
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 w
$newprice = sprintf("$%.2f", 15.109);
On Sun, Jan 10, 2010 at 8:36 PM, Rick Dwyer 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 = "$".number_format($ol
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
17 matches
Mail list logo