IonicWind Software

IWBasic => Database => Topic started by: Brian on January 03, 2021, 09:32:35 AM

Title: Doing Database money
Post by: Brian on January 03, 2021, 09:32:35 AM
I have been messing about testing which would be the best data type to use with an MDB for money calculations, to avoid rounding errors
It does seem the way to do it is define your money field as CURRENCY in the MDB (which I honestly didn't think you could do), and then access it in IWB with a DOUBLE variable, and using SETPRECISION 2
Play with the code, and see the results of using CURRENCY, FLOAT and INT
I have used SETPRECISION 8 in this example, to show the rounding errors using FLOAT

Currency (I have read on the internet) is a data type that is called a scaled integer (so it is an integer value that ALSO stores the number of decimal places). These numbers are thus not floating point numbers but are stored as exact values along with a decimal placeholder

Brian

Edit: Slight speed modification
Title: Re: Doing Database money
Post by: h3kt0r on January 19, 2021, 07:00:40 PM
Great ! Thank you for sharing the code.