Accuracy and the power function
02-23-2014, 08:09 PM (This post was last modified: 02-24-2014 06:54 AM by Thomas Klemm.)
Post: #15
 Thomas Klemm Senior Member Posts: 1,688 Joined: Dec 2013
RE: Accuracy and the power function
(02-23-2014 02:19 PM)Dieter Wrote:  I would also be interested very much in information on this matter regarding 10-digit devices with 13-digit internal precision, for instance the 41-series.

Not for the HP-41C but for the HP-15C I analyzed the Debug Trace in Nonpareil.
As far as I understand there is no "Sticky Bit". Excessive digits are lost.
The result (13 digits) is then rounded half away from zero to 10 digits.
The trick used is to double these last 3 digits and check for a carry.
• 499+499=998 => no carry
• 500+500=1000 => carry
In case of a carry 1 is added to the result. Which could set the carry again.
But this is handled separately and I have no trace added for this scenario.

Though I didn't check the sources of the HP-48 I assume the same algorithm is used.

Kind regards
Thomas

5.020000121e13 + 4999:
Shift right register c. The 9 at the end of 4999 is lost:
Code:
a=04999000000513 b=00000000000513 c=00000000004999
10364: 1716 c sr    w
cycle 150136  P=3 q=4 carry=0  stat=..............
a=04999000000513 b=00000000000513 c=00000000000499

Add both numbers in a and b now that they are alligned:
Code:
a=00000000000499 b=05020000121000 c=00000000000513
10376: 0456 a=a+b   w
cycle 150147  P=2 q=4 carry=0  stat=..............
a=05020000121499 b=05020000121000 c=00000000000513

Round half away from zero:
Code:
a=05020000121499 b=00000000000013 c=05020000121499
07406: 0746 c=c+c   x
cycle 150170  P=c q=4 carry=0  stat=..............
a=05020000121499 b=00000000000013 c=05020000121998
07407: 0153 ?nc goto 07424
cycle 150171  P=c q=4 carry=0  stat=..............
a=05020000121499 b=00000000000013 c=05020000121998
07424: 0306 c=b     x
cycle 150172  P=c q=4 carry=0  stat=..............
a=05020000121499 b=00000000000013 c=05020000121013

5.020000121e13 + 5009:
Shift right register c. The 9 at the end of 5009 is lost:
Code:
a=05009000000513 b=00000000000513 c=00000000005009
10364: 1716 c sr    w
cycle 154224  P=3 q=4 carry=0  stat=..............
a=05009000000513 b=00000000000513 c=00000000000500

Add both numbers in a and b now that they are alligned:
Code:
a=00000000000500 b=05020000121000 c=00000000000513
10376: 0456 a=a+b   w
cycle 154235  P=2 q=4 carry=0  stat=..............
a=05020000121500 b=05020000121000 c=00000000000513

Round half away from zero:
Code:
a=05020000121500 b=00000000000013 c=05020000121500
07406: 0746 c=c+c   x
cycle 154258  P=c q=4 carry=1  stat=..............
a=05020000121500 b=00000000000013 c=05020000121000
07407: 0153 ?nc goto 07424
cycle 154259  P=c q=4 carry=0  stat=..............
a=05020000121500 b=00000000000013 c=05020000121000
07410: 1072 c=c+1   m
cycle 154260  P=c q=4 carry=0  stat=..............
a=05020000121500 b=00000000000013 c=05020000122000
07411: 0133 ?nc goto 07424
cycle 154261  P=c q=4 carry=0  stat=..............
a=05020000121500 b=00000000000013 c=05020000122000
07424: 0306 c=b     x
cycle 154262  P=c q=4 carry=0  stat=..............
a=05020000121500 b=00000000000013 c=05020000122013

5.020000124e13 + 4999:
Shift right register c. The 9 at the end of 4999 is lost:
Code:
a=04999000000513 b=00000000000513 c=00000000004999
10364: 1716 c sr    w
cycle 169908  P=3 q=4 carry=0  stat=..............
a=04999000000513 b=00000000000513 c=00000000000499

Add both numbers in a and b now that they are alligned:
Code:
a=00000000000499 b=05020000124000 c=00000000000513
10376: 0456 a=a+b   w
cycle 169919  P=2 q=4 carry=0  stat=..............
a=05020000124499 b=05020000124000 c=00000000000513

Round half away from zero:
Code:
a=05020000124499 b=00000000000013 c=05020000124499
07406: 0746 c=c+c   x
cycle 169942  P=c q=4 carry=0  stat=..............
a=05020000124499 b=00000000000013 c=05020000124998
07407: 0153 ?nc goto 07424
cycle 169943  P=c q=4 carry=0  stat=..............
a=05020000124499 b=00000000000013 c=05020000124998
07424: 0306 c=b     x
cycle 169944  P=c q=4 carry=0  stat=..............
a=05020000124499 b=00000000000013 c=05020000124013

5.020000124e13 + 5009:
Shift right register c. The 9 at the end of 5009 is lost:
Code:
a=05009000000513 b=00000000000513 c=00000000005009
10364: 1716 c sr    w
cycle 173995  P=3 q=4 carry=0  stat=..............
a=05009000000513 b=00000000000513 c=00000000000500

Add both numbers in a and b now that they are alligned:
Code:
a=00000000000500 b=05020000124000 c=00000000000513
10376: 0456 a=a+b   w
cycle 174006  P=2 q=4 carry=0  stat=..............
a=05020000124500 b=05020000124000 c=00000000000513

Round half away from zero:
Code:
a=05020000124500 b=00000000000013 c=05020000124500
07406: 0746 c=c+c   x
cycle 174029  P=c q=4 carry=1  stat=..............
a=05020000124500 b=00000000000013 c=05020000124000
07407: 0153 ?nc goto 07424
cycle 174030  P=c q=4 carry=0  stat=..............
a=05020000124500 b=00000000000013 c=05020000124000
07410: 1072 c=c+1   m
cycle 174031  P=c q=4 carry=0  stat=..............
a=05020000124500 b=00000000000013 c=05020000125000
07411: 0133 ?nc goto 07424
cycle 174032  P=c q=4 carry=0  stat=..............
a=05020000124500 b=00000000000013 c=05020000125000
07424: 0306 c=b     x
cycle 174033  P=c q=4 carry=0  stat=..............
a=05020000124500 b=00000000000013 c=05020000125013
 « Next Oldest | Next Newest »

 Messages In This Thread Accuracy and the power function - Dieter - 02-16-2014, 02:43 PM RE: Accuracy and the power function - Joe Horn - 02-16-2014, 03:11 PM RE: Accuracy and the power function - Dieter - 02-16-2014, 05:45 PM RE: Accuracy and the power function - Joe Horn - 02-16-2014, 10:11 PM RE: Accuracy and the power function - Dieter - 02-18-2014, 08:28 PM RE: Accuracy and the power function - Joe Horn - 02-19-2014, 12:33 AM RE: Accuracy and the power function - Werner - 02-19-2014, 09:54 AM RE: Accuracy and the power function - walter b - 02-19-2014, 11:36 AM RE: Accuracy and the power function - Dieter - 02-19-2014, 12:35 PM RE: Accuracy and the power function - Werner - 02-19-2014, 11:47 AM RE: Accuracy and the power function - Werner - 02-19-2014, 01:07 PM RE: Accuracy and the power function - Dieter - 02-20-2014, 05:17 PM RE: Accuracy and the power function - Werner - 02-21-2014, 07:11 AM RE: Accuracy and the power function - Dieter - 02-23-2014, 02:19 PM RE: Accuracy and the power function - Thomas Klemm - 02-23-2014 08:09 PM RE: Accuracy and the power function - Werner - 02-23-2014, 09:06 PM

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