Why not FP for Money?

Tim Roberts timr at probo.com
Thu Sep 23 23:45:48 EDT 2004


Dennis Lee Bieber <wlfraed at ix.netcom.com> wrote:

>On 22 Sep 2004 22:03:43 -0700, Barkmann at gmail.com (Chris Barker)
>declaimed the following in comp.lang.python:
>
>> binary FP, you can't represent 1/10 of a cent exactly, but you can get
>> darn close, and if you round the answer to pennies when your done, it
>> will be just as accurate as decimal (given how many bit you use,
>> etc.), in general.
>>
>	Note that M$ VB "Money" data type (which I believe is a scaled
>double binary integer) purportedly goes to the hundredth of a cent.

Exactly correct.  It is a 64-bit scaled integer, scaled by 10000.  The
Currency data type has been dropped in VB.NET; they now have a full-fledged
Decimal type.
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list