[Chicago-talk] (no subject)

Sean Blanton sean at blanton.com
Mon May 7 10:16:21 PDT 2012


Yes, I'm late to the party on this. Certain types of rounding are
required in financial transactions and printf would be WRONG in the
last one I did. Printf has one type of rounding and it is only correct
if that is the type of rounding you need. Choosing a specific rounding
method can also prevent biases from arising in certain statistical
samples (if your numbers tend to end in an even digit for example).  I
suggest the obvious reference:

http://en.wikipedia.org/wiki/Rounding_numbers

Math::Round is great. FYI, SQL Server has poor rounding functionality,
so do it in Perl!

I actually had to unround numbers recently. It's possible if you know
the original # is a multiple of 1/16 or 1/32 ;)

Regards,
Sean



On Sat, Apr 28, 2012 at 9:06 PM, Andy Lester <andy at petdance.com> wrote:
>
> On Apr 28, 2012, at 3:27 PM, David Mertens wrote:
>
> On Sat, Apr 28, 2012 at 3:14 PM, Alexander
> Danel <danel at speakeasy.net> wrote:
>>
>> The correct way to round numbers in Perl is "printf()" and "sprintf()".
>
>
> perldoc -q round
>
> perldoc -q says "Search the FAQ".
>
> xoa
>
> --
> Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
>
>
> _______________________________________________
> Chicago-talk mailing list
> Chicago-talk at pm.org
> http://mail.pm.org/mailman/listinfo/chicago-talk


More information about the Chicago-talk mailing list