Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Converting Decimal Degrees to D:M:S in excel

Posted on 2016-09-07
7
Medium Priority
?
107 Views
Last Modified: 2016-09-09
Can someone explain why I'm getting rounding errors in the attached spread sheet?  DDtoDMS.xlsx

I'm expecting column 'T' to look like this

42:33:00:N/001:34:59.88:W

Open in new window


If E3 =0.55 and F3 = "E3*60"/33 so how can G3 = "INT(F3)" / 32?

My maths might be dodgy but 0.55 *60 = 33

Also how do I fix the leading zeros in the output?
0
Comment
Question by:trevor1940
  • 4
  • 2
7 Comments
 
LVL 34

Expert Comment

by:Rob Henson
ID: 41788098
That is bizarre to say the least!!

If you copy E2 and paste values elsewhere, it gives 0.549999999999997 hence why that value multiplied by 60 doesn't give an exact 33.

Change the formula in E2 to:

=ROUND(C2-D2,2)

That sorts it.

I don't see any leading zeros in the output.

Thanks
Rob H
0
 
LVL 34

Expert Comment

by:Rob Henson
ID: 41788120
To force the numbers to show as a certain number of digits, you can use the TEXT function, your end result formula becomes:

=CONCATENATE(TEXT(D2,"000"),":",TEXT(G2,"00"),":",TEXT(I2,"00"),":",B2,"/",TEXT(M2,"000"),":",TEXT(P2,"00"),":",TEXT(R2,"00"),":",K2)

Change the number of 0 in the " " to affect how the number appears.
0
 
LVL 34

Accepted Solution

by:
Rob Henson earned 1600 total points
ID: 41788168
Alternatively, this formula gives the same result but without using helper columns, ie just using Decimal Degrees and Hemisphere columns (A & B and J & K):

=CONCATENATE(TEXT(INT(ABS(A2)),"000"),":",TEXT(INT(ROUND(MOD(ABS(A2),1),2)*60),"00"),":",TEXT(ROUND(MOD(ROUND(MOD(ABS(A2),1),2)*60,1),2)*60,"00"),":",B2,"/",TEXT(INT(ABS(J2)),"000"),":",TEXT(INT(ROUND(MOD(ABS(J2),1),2)*60),"00"),":",TEXT(ROUND(MOD(ROUND(MOD(ABS(J2),1),2)*60,1),2)*60,"00"),":",K2)

In addition, your Hemisphere calculations can be simpler:

North/South =IF(A2<0,"S","N")
East/West =IF(J2<0,"W","E")

That could even be incorporated into the main formula so just using the Decimal Degrees in columns A & J:

=CONCATENATE(TEXT(INT(ABS(A2)),"000"),":",TEXT(INT(ROUND(MOD(ABS(A2),1),2)*60),"00"),":",TEXT(ROUND(MOD(ROUND(MOD(ABS(A2),1),2)*60,1),2)*60,"00"),":",IF(A2<0,"S","N"),"/",TEXT(INT(ABS(J2)),"000"),":",TEXT(INT(ROUND(MOD(ABS(J2),1),2)*60),"00"),":",TEXT(ROUND(MOD(ROUND(MOD(ABS(J2),1),2)*60,1),2)*60,"00"),":",IF(J2<0,"W","E"))

Thanks
Rob

EDITED 17:31: To correct missing ABS statements
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 23

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 400 total points
ID: 41788283
Looking at formula in K:
use the ROUND function on values in column I and R. Internally, Excel is storing values as double-precision data type, which is stored in exponential format and therefore, not precise. Any calculation made should be rounded to the desired precision as that is not implicitly determined by the factors.
0
 
LVL 1

Author Comment

by:trevor1940
ID: 41788339
Hi Rob


If you copy E2 and paste values elsewhere, it gives 0.549999999999997 hence why that value multiplied by 60 doesn't give an exact 33.

Change the formula in E2 to:

=ROUND(C2-D2,2)

Any idea why this happening?

Thanx for your 1 cell solution very neat I had opened up my solution to work where this error was

BTW Latitude can only be 2 digits for degrees only saying

@crystal


use the ROUND function on values in column I and R. Internally,

How will that help?  hasn't the damage already been made at this point?

I don't understand how 42.55 - 42 doesn't = 0.55?  is there a format setting some where causing this error?
0
 
LVL 34

Expert Comment

by:Rob Henson
ID: 41789688
Crystal has answered the question as why Excel is doing this, much as it is annoying I don't think there is a lot that can be done about it other than allowing for it with ROUND functions.
0
 
LVL 1

Author Closing Comment

by:trevor1940
ID: 41790802
Thanx for you help and explanation
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question