1. Registered User
Join Date
Oct 2003
Posts
8

I wonder can someone explain this to me:

I have a table that I enter grades for a student. One grade is for the evaluation and the other for the exam.
In a query I get the average of these two values by adding the two fields and dividing by 2. This gives me the total. However, when I put 8.5 as the evaluation 9.8 as the exam result, instead of getting 9.15 (the correct mathematical result), I get 9.1499996185? This is wrong and then causes problems in reports as rounded to one decimal place the result becomes 9.1 instead of 9.2 which it should be if the correct answer 9.15 was given.

In the same area why, when I set field properties as General Number and 1 decimal place do I always get more than one decimal place in my result? In the case of my example it goes up to 14.

2. Join Date
Jun 2003
Location
USA
Posts
1,032
I always like to use a rounding function (such as jpsRound() in the sample database found at www.bullschmidt.com/access) when multiplying or dividing.

3. Registered User
Join Date
Oct 2003
Posts
8
Thanks. Still can't understand why 2 numbers can't be divided properly to start with.

4. Grand Poobah
Join Date
Sep 2003
Location
MI
Posts
3,713
roller,

There is always a rounding error when dealing with floats and doubles ...

5. Registered User
Join Date
Oct 2003
Posts
8
Thanks

I can understand a rounding error on a complicated mathematical formula, but the example I gave would appear to be quite simple as the correct answer comes to 2 decimal places and not 14 as appears in the query and this shouldn't leave much room for error. As far as I can see rounding difficulties wouldn't even come into it if the calculation was done correctly to start with. There is obviously something beyond my knowledge of Maths and computers that I don't know about so sorry for rant.

Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•