Need decimal places in calculation

jmccullough

Registered User.
Local time
Today, 09:48
Joined
Jul 30, 2007
Messages
24
I need to calculate the number of days divided by 180 times the number of Units and have it return a number with 7 decimal places. My calculation keeps dropping the decimal places.

As an example, I have two (2) fields in my table:

Field Name Data Type Field Size
Units Number Double
Days Number Double

For my example I will use the following:

122 days 9 Units

My calculation in my query is (122/180)*9 it returns 6.1 and I need it to return 6.0999993

I hope this makes sense. Using access 2010. What am I doing wrong? Any help please.
 
I don't know if that's possible, considering that (122/180)*9 actually equals exactly 6.1
 
If it's just the case that you want to display these characters so that your numbers look consistent, then you could look at adding trailing zeros. Basically you would turn the number into a string, count the number of characters and then add a number of zeros to give the correct number of trailing Zeros for the format you require. More information in this Google search:- "trailing zeros" -leading I'm not sure but it might be worth looking at the MS Access format function, it might well be able to provide you with the correct format although, seeing as the number is perfectly 6.1 then I'm not so sure.
 
Last edited:
Thank you both for the quick reply. I guess I will try and convert as string and try formatting the field.

Can someone tell me why though when you perform the calculation on a calculator it displays as: 6.0999993, just curious.

(122/180)*9 = 6.0999993

Thanks for your help again.
 
Did someone just ask for a math lesson? Put me in coach.

On some calculators you will get 6.0999993 for the same reason 2/3 has its last decimal digit as a 7 (e.g. .666667)--it has a limited precision. Better yet, that limitation is handled differently by the display than by the memory of a calculator.

In your calculation when you do the first operation (122/180) the display rounds the result to something like .6777778, but the memory of the caclulator stores it by truncating it like .67777777. So when you do the next operation (*9) you get 6.0999993 even though .6777778*9 should come out to 6.100001
 
I copied the equation in to the Chrome Browser bar. I don't know how accurate it is, but just to say it returned the correct answer in this case.
 

Users who are viewing this thread

Back
Top Bottom