best way of dealing with currency?

Diez B. Roggisch deets at nospam.web.de
Tue Oct 16 15:57:48 EDT 2007


Paul Miller schrieb:
> I'm looking at doing some currency calculations in some Python code 
> integrated with a C++ application. I want to be able to come up with the 
> same values I get in an Excel spreadsheet.
> 
> I've been poking around for a couple of days and haven't come across a 
> definitive method for dealing with currency in a precise manner.
> 
> What do I need to do? Use rationals? Very high-precision floating-point? 
>  mxNumber? Or something else?

The module decimal. But in the end, you might not be able to recreate 
the same values as excel, due to the unknown intricacies of excel.

Diez



More information about the Python-list mailing list