Post Reply 
H->HMS conversion HP-15C vs. HP42S vs HP67
09-12-2018, 02:08 PM (This post was last modified: 09-13-2018 02:24 AM by Albert Chan.)
Post: #53
RE: H->HMS conversion HP-15C vs. HP42S vs HP67
(09-12-2018 07:06 AM)Werner Wrote:  Why not

DMS->DEG: (250*X-INT(100*X+0.25)-60*INT(X))/90

(09-12-2018 07:14 AM)Werner Wrote:  T := HMS*100;
T := T - IP(T+0.25);
T := HMS + T/150;
HR := T + FP(T)/1.5;

Correctly implemented strtod guaranteed maximum error 0.5 ULP
Scaling by constant also guaranteed maximum error of 0.5 ULP
So, scaled value can at most be 1 ULP below User Decimal Input (where 40 second bug might hit)
Ideally, we want 1 ULP correction: nextafter(100*X, 200*X)

X*100.00000000000001 might correct 1 to 2 ULP (due to rounding).
But, (possible) 1 ULP over-correction is good enough.
The patched version is also fast, same as un-patched version. Smile

Too big over-correction, however, may mis-interpret what the user entered.
Both Pekis and Meyers "+25 seconds" patches have similar counter-examples:

For negative angles, patches make it worse, say, X = -0.10, under-counted 40 seconds.
For positive angles, 75+ seconds, it "fixed" a phantom bug, under-counted 40 seconds.

Example: 85 seconds, both patches returned 0.0125 degree (= 45 seconds).

The patches are not wrong, but limited (non-negative angles and no "bad" seconds).
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-12-2018 02:08 PM



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