Welcome to the NavList Message Boards.

NavList:

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

Compose Your Message

Message:αβγ
Message:abc
Add Images & Files
    or...
       
    Reply
    Re: Calculators, cosines, and floating point computation
    From: Brad Morris
    Date: 2019 Jun 10, 14:39 -0400
    Frank

    Sometimes, I misspell a word.  It happens.  Whoops!

    I somehow missed that calculation and comparison trick.  Not the calculation part.  The comparison of the calculated value with the define as a way to guard against sneaky errors.

    #defines were plenty good enough for me.  Define more digits than you need for floating point implementation. Diff the code against the prior version, prior to placing code into version control.  Fairly well eliminates keystroke errors (except the initial case).

    I'd say we have drifted well away from CN by this point.  Call this thread a wrap?

    Brad 

    On Mon, Jun 10, 2019, 1:33 PM Frank Reed <NoReply_FrankReed@fer3.com> wrote:

    Brad, you wrote:
    "I like the trick of a computation compared to the define. Clever."

    Haven't seen that one, eh? It's right out of the Mesozoic! Representing pi as 4·atan(1) used to be quite standard coding practice ...in the before time ...when code came on cards.

    You wrote:
    "I was tasked at GE with finding an indideous bug. "

    I think I found the source of your bug. :)

    Back to π... calculating tricks, like using the atan or the acos were common even two decades ago, but most languages and computation tools now provide a "safe" internal pi. You can search on "math.pi" for examples of these. You'll find some variant of that constant in the "math" object in javascript, lua, python, java... the list goes on. And in most spreadsheets, you get a system-precision limited value for pi using a standard math function =pi(). For everything you might ever do in navigation, these built-in values are the way to go. There are still rare cases where you may want more digits for some exercise in pure mathematics, and this is a nice application of Wolfram Alpha. Want pi to fifty digits? Then query with that exact text: https://www.wolframalpha.com/input/?i=pi+to+50+digits.

    Frank Reed
    PS: A reminder: the radius of the Earth is 3438 nautical miles... 'cause there's pi inside...

    File:


    View and reply to this message

       
    Reply
    Browse Files

    Drop Files

    NavList

    What is NavList?

    Join NavList

    Name:
    (please, no nicknames or handles)
    Email:
    Do you want to receive all group messages by email?
    Yes No

    You can also join by posting. Your first on-topic post automatically makes you a member.

    Posting Code

    Enter the email address associated with your NavList messages. Your posting code will be emailed to you immediately.
    Email:

    Email Settings

    Posting Code:

    Custom Index

    Subject:
    Author:
    Start date: (yyyymm dd)
    End date: (yyyymm dd)

    Visit this site
    Visit this site
    Visit this site
    Visit this site
    Visit this site
    Visit this site