ashwini kalmath

Greenhorn

Posts: 25

posted 5 years ago

I don't think you'll find an API, but the math is simple enough.

vFraction = (value * 3600) % 3600

vMinutes = vFraction / 60

vSeconds = vFraction % 60

If I haven't mess up the "vFraction" calculation, that should do it.

vFraction = (value * 3600) % 3600

vMinutes = vFraction / 60

vSeconds = vFraction % 60

If I haven't mess up the "vFraction" calculation, that should do it.

An IDE is no substitute for an Intelligent Developer.

ashwini kalmath

Greenhorn

Posts: 25

posted 5 years ago

hello Tim Holloway,

i did the conversion in another way and i got it. but still me bit curios to know how exactly the calculation done as you said?

can you explain me with some example? let me give you the values wait............

degree decimal format : 13.025493599706797

i need to get the value in degree minutes format that is as :1301.5296N

can you solve it and get that value as result?

Thank you:-)

i did the conversion in another way and i got it. but still me bit curios to know how exactly the calculation done as you said?

can you explain me with some example? let me give you the values wait............

degree decimal format : 13.025493599706797

i need to get the value in degree minutes format that is as :1301.5296N

can you solve it and get that value as result?

Thank you:-)

posted 5 years ago

I think this comes in somewhere around the basic Geometry maths class.

In the traditional Babylonian-inspired circular metric system, a circle encompasses exactly 360 degrees. Each degree was divided into 60 minutes, each minute was divided into 60 seconds. That pretty well tapped out their limits of precision, so after that you're on your own - we use decimal fractions on seconds.

So:

13.025493599706797°

Removing the integer part, gives:

0.025493599706797°

Scale it up by 3600.0 (60×60):

91.776958944'

Div/mod, gives:

91.776958944 / 60 = 1.529615'

91.776958944 % 60 * 60 = 31.776958944"

So, in traditional form:

13°01'31.777" (approx). Assuming North latitude from a signed number: 13°01'31.777N

Or, since you only want degrees/minutes:, multiply by 60 and skip the seconds calculations, instead:

13° 1.529615982'N

Which you can verify approximately, since 1'30" is exactly 1.5 minutes, by definition.

In the traditional Babylonian-inspired circular metric system, a circle encompasses exactly 360 degrees. Each degree was divided into 60 minutes, each minute was divided into 60 seconds. That pretty well tapped out their limits of precision, so after that you're on your own - we use decimal fractions on seconds.

So:

13.025493599706797°

Removing the integer part, gives:

0.025493599706797°

Scale it up by 3600.0 (60×60):

91.776958944'

Div/mod, gives:

91.776958944 / 60 = 1.529615'

91.776958944 % 60 * 60 = 31.776958944"

So, in traditional form:

13°01'31.777" (approx). Assuming North latitude from a signed number: 13°01'31.777N

Or, since you only want degrees/minutes:, multiply by 60 and skip the seconds calculations, instead:

13° 1.529615982'N

Which you can verify approximately, since 1'30" is exactly 1.5 minutes, by definition.

An IDE is no substitute for an Intelligent Developer.

It is sorta covered in the JavaRanch Style Guide. |