|Re: Hp 28s number format - the final program|
Message #9 Posted by Vieira, Luiz C. (Brazil) on 4 Oct 2002, 2:04 p.m.,
in response to message #7 by joan cardenas
The first version of this program took me a little bit longer because I had to drive my daughter to school.
Later, some complications were detected, sometimes when STD mode was set, others when FIX mode was set. I realised that the same number will have a different character size in both representation, and that was the major trouble. We know that, but the program must detect it.
I know the final program (shown here) is somewhat big, but I did not refine it. Here is the listing: (A1 is an auxiliary program; the main one I named THO, for thousand)
« IF OVER SIZE == THEN "0" SWAP + END »
It will work fine with negative numbers with FIX or STD modes, regardless radix mark type (it detects). Also, exponent of ten should be less than 12. If you use ENG or SCI, resulting display will be awkward.
« DUP ABS RCLF -> N F
« N FP ->STR
IF DUP SIZE 1 ==
THEN DROP ""
IF DUP 1 1 SUB "0" ==
THEN 2 OVER SIZE SUB
END -> W
« 0 FIX ""
WHILE N XPON 2 >
REPEAT 48 FC? "," "." IFTE N 1000 / DUP 'N' STO FP 1000 * IP ->STR 2 A1 3 A1 1 3 SUB + SWAP +
END N IP ->STR 1 OVER SIZE 1 - SUB SWAP + W + OVER 0 <
THEN "-" SWAP +
END F STOF 1 DISP
I am almost sure it can be smaller, but I did not take the time to shorten it. If someone else has a shorter version, please, post it here.
Hope it helps.