Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Degrees, minutes and seconds to Decimal Degrees

Degrees, minutes and seconds to Decimal Degrees

Scheduled Pinned Locked Moved C#
helptutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Darrall
    wrote on last edited by
    #1

    Does anybody know how to do this with the information entered in this format? ##.#### I thought it might be in the Math class but isn't. Thanks for any help.

    T R 2 Replies Last reply
    0
    • D Darrall

      Does anybody know how to do this with the information entered in this format? ##.#### I thought it might be in the Math class but isn't. Thanks for any help.

      T Offline
      T Offline
      Tarakeshwar Reddy
      wrote on last edited by
      #2

      Darrall wrote:

      I thought it might be in the Math class but isn't.

      Wikipedia does http://en.wikipedia.org/wiki/Geographic_coordinate_conversion[^].


      Tarakeshwar Reddy There are two kinds of people, those who do the work and those who take the credit. Try to be in the first group; there is less competition there. - Indira Gandhi

      1 Reply Last reply
      0
      • D Darrall

        Does anybody know how to do this with the information entered in this format? ##.#### I thought it might be in the Math class but isn't. Thanks for any help.

        R Offline
        R Offline
        Roger Wright
        wrote on last edited by
        #3

        It's not a built-in function, but it's certainly not hard to do the arithmetic. Subtract the int part of ##.#### from the original. The remainder will be .####. Multiply that by 60 and again take the int part of the result - that's the minutes. Subtract the minutes from the result of the first multiplication, then multiply the result by 60 again. The result is the seconds, though there may be a decimal part in the result if the original datum wasn't an integral number of seconds. You can remove that if you don't want it by again taking only the int part of the result. I don't yet have enough experience with the language to suggest the syntax - for all I know, Convert.ToInt() might round, rather than truncate real values. If so you'll have to try another dodge. But it shouldn't be too difficult to manage. It's such a frequent problem, though, that I'm rather surprised that MS didn't include it as a stock function.

        "A Journey of a Thousand Rest Stops Begins with a Single Movement"

        D 1 Reply Last reply
        0
        • R Roger Wright

          It's not a built-in function, but it's certainly not hard to do the arithmetic. Subtract the int part of ##.#### from the original. The remainder will be .####. Multiply that by 60 and again take the int part of the result - that's the minutes. Subtract the minutes from the result of the first multiplication, then multiply the result by 60 again. The result is the seconds, though there may be a decimal part in the result if the original datum wasn't an integral number of seconds. You can remove that if you don't want it by again taking only the int part of the result. I don't yet have enough experience with the language to suggest the syntax - for all I know, Convert.ToInt() might round, rather than truncate real values. If so you'll have to try another dodge. But it shouldn't be too difficult to manage. It's such a frequent problem, though, that I'm rather surprised that MS didn't include it as a stock function.

          "A Journey of a Thousand Rest Stops Begins with a Single Movement"

          D Offline
          D Offline
          Darrall
          wrote on last edited by
          #4

          Thanks Roger. I know the conversion itself is simple if you're sitting there doing it on a calculator. It becomes fairly complicated using C# code though which is why I was surprised there wasn't already a Math function for it. They have sin, cos and tan which all work in angles and in the real world - surveying, mapping, navigation, etc. - angles come in degrees, minutes and seconds. I will pass my method along once I have finished it in case anybody else wants it. Thanks for your feedback.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups