View Full Version : Rounding Problems in Access 97 - Anyone Else?


ccmis
04-25-2002, 12:29 PM
I always have problems while doing calculations in queries that cause rounding problems (that make no sense).

For example, I have a number that I want to collect a 5% commission on. On some records, I would say about once every 20-25 records, when I multiply the 1895.22 x .05 I get an answer back of say 94.761. When I run it through the RoundCC() module it will sometimes come up as 94.7612399845 or something wild like that. Is this a bug in Access 97. I constantly run into this. Does this kind of thing happen in Access 2000? I remember COBOL and RPG, when you used a rounding command it rounded up to the next whole cent and was done.

Pat Hartman
04-25-2002, 04:00 PM
There are times (not many though) when I look back fondly on coding in COBOL and this is one of them. The difference is caused because in most business applications we always defined our numeric fields in some fixed point data type such as COMP or COMP-3 and only rarely used the floating point types of COMP-1 and COMP-2. Therefore the math processor used fixed point arithmatic and scalled the results based on the implied decimal point (that's twice this week that I've mentioned implied decimal points) in the picture clause of the destination field. I think that the Access currency data type works much like the fixed point data types we were used to on the mainframe with the difference being that decimal digits are fixed at 4. Your display format usually limits that to 2 when the field is actually currency. But, you can store any type of numeric values in a currency field including percents as long is 4 decimal digits are sufficient.

Look up the article titled "When Access Math doesn't add up" on the www.fmsinc.com (http://www.fmsinc.com) website. It explains the problem in some depth. There are also many other worthwhile articles to read while you're there.

[This message has been edited by Pat Hartman (edited 04-25-2002).]