From: Terrel S. <tsh...@tr...> - 2001-03-22 17:45:10
|
Jeff Johnson wrote: > Hi, > > I've been reading the MiddleKit docs and have a simple question. How do we > represent money? Should it be an int that we divide by 100 to get the > value? I think a float would have rounding errors. I see a some code for > Decimal but don't see it in the list of types in the docs. > This seems like a very USD centric view. I find it hard to believe that there is no currency in the world that does not use some other multiplier. (I could be wrong.) If you care about accuracy, and especially if you care about handling multiple currencies, I would recommend staying away from the SQL money types. Storing them as integers with a scale factor as you suggested is a better solution. > > While I'm asking, maybe someone has experience using Money types from MS SQL > Server 7.0 via pyWin32 and ADO? When we query the database it returns money > types as a two element tuple, usually "(0, 450000)" if the money amount was > $45.00. But not always, sometimes it's a negative value that's close but > not exactly = -1 * amount * 1000. We ended up having to cast the value to a This is probably a decimal/binary conversion issue. See http://www2.hursley.ibm.com/decimal/decifaq.html for more information. (http://www.ibm.com/Search?v=10&lang=en&cc=us&q=decimal+arithmetic for a lot more information.) |