Post Reply 
H->HMS conversion HP-15C vs. HP42S vs HP67
09-08-2018, 12:59 PM (This post was last modified: 09-08-2018 01:10 PM by Albert Chan.)
Post: #27
RE: H->HMS conversion HP-15C vs. HP42S vs HP67
(09-07-2018 02:40 PM)Thomas Okken Wrote:  The approach I chose for ->HR for the binary version is robust but not very pretty: multiply x by 1e12,
round to nearest integer, and then do everything using integer math.

Plus, there is a special case in for |x| < 0.01, where the conversion reduces to a simple division by 0.36.

Hi, Thomas Okken

Just a crazy example, billion degrees 4 minutes.

X = 1000000000.03999996185 ... (binary float)
X * 1e12 = 1000000000039999897600 (binary, exact integer)

With this value, result will be over-counted ~ 100 - 60 = 40 seconds (just like Retro12C)
(note: this is only based on your comment, I have not try it on the actual emulator)

Instead of nearest integer, it might be better with rounded 12 digits value (no scaling needed).
12 digits can safely pushed to 15, see

For accurate dtoa, David Gay's dtoa.c is well tested:
Or, you can try my code: Smile

Edit: some good C compiler can do correct strtod and dtoa functions. With those, above code is not needed
Find all posts by this user
Quote this message in a reply
Post Reply 

Messages In This Thread
RE: H->HMS conversion HP-15C vs. HP42S vs HP67 - Albert Chan - 09-08-2018 12:59 PM

User(s) browsing this thread: 1 Guest(s)