Storing a great many fields in a database
Peter M. Brigham
pmbrig at gmail.com
Mon Jul 16 18:36:36 EDT 2012
On Jul 16, 2012, at 3:07 PM, Dr. Hawkins wrote:
>> As you noted, using REAL for currency arithmetic will get
>> you into rounding issues but sounds like that's not a problem. One
>> approach I've seen for currency values is to store them as integers
>> including the decimal places, e.g $100.00 would be stored as 10000, do the
>> arithemtic in that form, then insert the decimal point for display
>> purposes.
>
> Actually working with the pennies, desirable as it would be, creates
> new issues--displaying in livecode fields. I think it will be simpler
> to store in pennies, and convert to dollars while working, and back on
> save.
For his entire life, my father kept the running balances in his checkbook register in whole dollar amounts only, rounding each time he re-totaled. At the end of the year he was off by at most $2, usually accurate to the nearest dollar. In certain contexts, ignoring the small change doesn't matter at all for the big picture.
-- Peter
Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig
More information about the use-livecode
mailing list