Solved

Converting Decimal Degrees to D:M:S in excel

Posted on 2016-09-07
7
49 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 31

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 31

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 31

Accepted Solution

by:
Rob Henson earned 400 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 18

Assisted Solution

by:crystal (strive4peace) - Microsoft MVP, Access
crystal (strive4peace) - Microsoft MVP, Access earned 100 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 31

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now