A tiny synthetic HP41 challenge
12-07-2016, 07:17 PM (This post was last modified: 12-07-2016 07:21 PM by Dieter.)
Post: #1
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
A tiny synthetic HP41 challenge
I'm not an expert if it comes to synthetic programming on the HP41, so probably someone else here may have a better idea than me for the following little challenge.

The task: truncate a number after six or seven significant digits and normalize it to the domain 0 <= X < 1.

Some examples:
3,141592654 => 0,314159 or 0,3141592
ā1,234567809 Eā32 => 0,123456 or 0,1234567
9,999999999 E+99 => 0,999999 or 0,9999999
0,123456 => 0,123456

Here's my solution:

Code:
CLA ABS STO M ASTO M ASTO M ASTO M >"\x00\x09\x99" RCL M CLA END

The append command adds three bytes (decimal 0, 9, 153 or hex 00, 09, 99) to clear the last three digits and set the exponent to ā1.

I am sure you can do better. So what's your idea here?

Dieter
 « Next Oldest | Next Newest »

 Messages In This Thread A tiny synthetic HP41 challenge - Dieter - 12-07-2016 07:17 PM RE: A tiny synthetic HP41 challenge - hth - 12-08-2016, 06:25 PM RE: A tiny synthetic HP41 challenge - Dieter - 12-08-2016, 06:46 PM RE: A tiny synthetic HP41 challenge - hth - 12-08-2016, 08:34 PM RE: A tiny synthetic HP41 challenge - Dieter - 12-08-2016, 09:17 PM

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