I
I
Ilya2017-09-21 05:24:35
JavaScript
Ilya, 2017-09-21 05:24:35

How to correctly convert coordinates in the DD.DDDD format to the DDMMSS format?

There is a code:

dd = Math.trunc(dddddd);
mm = Math.trunc((dddddd - dd) * 60);
ss = Math.round((((dddddd - dd) * 60) - mm) * 60)

For minutes, I take an integer from the calculation, and for seconds, rounded.
Am I doing the right thing?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Kalibrov, 2017-09-21
@Rimush

Yes, you are doing everything right. Translation formulas:
DD = TRUNC(DDD)
MM = TRUNC((DDD − DD) * 60)
SS = ((DDD − DD) * 60 − MM) * 60
SS can be rounded as you did

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question