>
>  Is 'decimal' the best field type for storing financial amounts that will 
> be involved in math calculations?
>

I've been doing a lot of research on the decimal vs float thing for a 
while, and every database admin I've ever talked to about it says the same 
thing: When it comes to financial calculations, decimal is the ONLY data 
type that should be used.

Python's Decimal is a real pain, but I have managed to do plenty of 
calculations with it on Python 2.5 - 2.7 without having to modify my code. 
I have done this in the past by following one simple rule: Always 
initialize Decimal() with a string:

Decimal('2.5')

float_val = 3.2
Decimal(str(float_val))

It seems counter-intuitive to convert numbers to strings, only to have them 
converted to numbers again, but that's how Python wants it.

Reply via email to