Phantom multiple decimal places added when querying

E

Eric

I have source data that is definitely only one decimal place in length before
being copied and pasted from Excel into Access. When I query the data, the
results display as one decimal place--but when I copy & paste back into Excel
(or click on the query results in Access), the number expands to a miniscule
decimal higher or lower.

So, for example--a number entered as 1.6 in the data table returns as
1.600000002384186 when queried. 8.5 returns as 8.49999982118607. The source
data in Excel is definitely 1.6 and 8.5.

Any idea what's going on? It may seem insignificant, but my queries to find
values > 8.0 or < 8.0 pick up on these miniscule decimal differences and I
get some 8.0's in my results.
 
J

Jerry Whittle

You've been bit by the infamous Floating Point Math Problem. It's actually
pretty common in computers due to them not being Base10 in their math.

Debug.Print 3.1 - 3.11 = -9.99999999999979E-03 which is not the same as
-0.01.

If you only need up to two decimals, making that column a Currency data type
might be a good solution.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top