Question

I have a MS Access 2010 database with a products table. The price column is a single datatype with format set to Fixed(2). There are certain values that are not being represented correctly, and I've no idea why. For example, one price is shown in the table as 1.52. However, if I export to Excel, or view it in a form with the Currency format, I see that Access has really stored 1.51999998092651. No matter what I do, I can't seem to change the value to represent the 0.20 correctly.

I know that computers store reals as approximations, but this seems rather ridiculous. Any ideas what's going on here and how I can fix it?

Was it helpful?

Solution

Replace 'Single' datatype to 'Currency', or at least to 'Double'.

Floating point numbers in common do not have accurate binary representation. Certainly 'Double' type will have less mistakes. So you need to use fixed point numbers, named 'Currency' in ms access. But they have limited precession 15 digits before and 4 digits after point.

P.S. You have to change type, not format.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top