# NavList:

## A Community Devoted to the Preservation and Practice of Celestial Navigation and Other Methods of Traditional Wayfinding

**Re: Why do we still use this terrible Babylonian hexadecimal system**

**From:**Michael Dorl

**Date:**2004 Nov 19, 07:48 -0600

George: Thanks for pointing out these problems. I did this because I inherited a db with 10,000 stars with the angles in a single column. Here's the code with the DECtoDMS fixed up but not the other -0 problem. I don't know enough vb to fix that but I'll find out and post the code when I find out what needs to be done. Also should decide what should be done when there is only one or two fields. Eg. 12 or 12 34. Michael Function DMStoDEC(s As String) As Double Dim parts() As String Dim Degrees As Integer Dim Minutes As Integer Dim Seconds As Integer Dim sign As Integer parts = Split(s, , , vbBinaryCompare) Degrees = parts(0) If Degrees < 0 Then sign = -1 Degrees = -Degrees Else sign = 1 End If Minutes = parts(1) Seconds = parts(2) DMStoDEC = sign * (Degrees + Minutes / 60# + Seconds / 3600#) End Function Function DECtoDMS(A As Double) As String Dim Degrees As Integer Dim Minutes As Integer Dim Seconds As Double Dim sign As String If A < 0 Then A = -A sign = "-" Else sign = "" End If Degrees = Int(A) A = 60 * (A - Degrees) Minutes = Int(A) Seconds = 60# * (A - Minutes) Seconds = Round(Seconds, 3) Seconds = Int(Seconds * 1000#) Seconds = Seconds / 1000# DECtoDMS = sign & Degrees & " " & Minutes & " " & Seconds End Function At 10:15 AM 11/19/04 +0000, you wrote: >Comment from George- > >Cliff Sojourner responded to my comments about a possible weakness in Chuck >Taylor's angle conversion- > >"that's the first thing I checked in the VB code posted earlier; that one >got it right too." I presume Cliff is referring to Mike Dorl's routine, >quoted above > >But does Mike's routine get it right in all cases? I think I can see where >it might break down. > >How will it cope with an angle that's -0deg 30'? > >The test for negative angle is made only on the degrees, not minutes or >seconds. > >So, in that example, it has to make the test as to whether -0 is less than >zero. > >I am unfamiliar with the Visual Basic that's in use here (my pocket >calculator uses a much more rudimentary form of Bsic) but I suspect most >computing programs will answer that it isn't less than zero, in which case >Mike Dorl's program will fall down, treating an angle of -0deg 30' exactly >the same as +0deg 30', to give +0.5 deg where it should have been -0.5 deg. > > >A safer test for negativity might be to search for a "minus" character, >somewhere in the string. > >Mike may have checked this aspect already, but if not he would be wise to >try out his routine on an angle that's negative, and less than 1 degree. > >What's more, I have a strong suspicion that Mike's converse routine for >degrees-to-dms will go wrong for any negative angle: I certainly recommend >that he checks it out. Try converting -0.25deg, wich ought to give a result >of -15'; I suspect that it will give -45'. > >I have become aware of such possible waywardness in angle conversion only >by experience; in making such mistakes myself, then (the hard part) >uncovering them, then (the easy part) correcting them. > >George.