Decomposing a number into powers of two

Discuss software for the Apple 1/replica 1

Decomposing a number into powers of two

Postby lorddoomicus » Jan Sun 25, 2009 12:49 am

This is the first step in me getting a program that does multiplication using the method described in the Rhind Papyrus for Egyptian Multiplication is decomposing a given number by powers of two.

This simple little program seems to do the trick.

Code: Select all
100 PRINT "DECOMP OF A NUMBER TO POWERS OF 2"
110 INPUT "ENTER A NUMBER: ",A
130 LET B=1
140 IF B>A THEN 170
150 LET B=B*2
160 GOTO 140
170 LET B=B/2
180 PRINT B
190 LET A= A - B : LET B=1
200 IF A=0 THEN END
210 GOTO 150


- Derrik
Derrik Walker v2.0, RHCE
http://www.doomd.net
lorddoomicus
 
Posts: 32
Joined: Sep Thu 07, 2006 10:30 pm
Location: Mentor Ohio

Return to Software

Who is online

Users browsing this forum: No registered users and 2 guests

cron