in reply to Re: Re: (Golf) Formatting Integer To Money
in thread (Golf) Formatting NumberTo Money
It seems that the sprintf solutions fail sometimes in rounding, e.g. "123456789012345.125" becomes "123,456,789,012,345.12" instead of "123,456,789,012,345.13".sub a{$_=sprintf"%.2f",@_;1while s/\B...\D/,$&/;$_}
Update: I was just informed by thospel++ that IEEE rounding is toward even, not upward. That explains the behavior, though I'm not sure if it's the desired behavior for this problem.
-- Mike
--
just,my${.02}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: (Golf) Formatting Integer To Money
by larryk (Friar) on Aug 29, 2002 at 20:55 UTC |