Post Reply 
Wanted: Efficient Algorithm to Square an Integer Number
03-06-2019, 11:47 PM
Post: #5
RE: Wanted: Efficient Algorithm to Square an Integer Number
Not the best method, but this can be done entirely with integer operations and no multiplications whatsoever (lines 17 & 18 and lines 20 & 21 are shift left and shift right operations, respectively).

More details in this old forum thread:

OT: primitive mult/div algorithms

00 { 43-Byte Prgm }
01▸LBL "ISQ"
02 ABS
03 0
04 STO 00
05 X<>Y
06 ENTER
07 ENTER
08▸LBL 00
09 CF 00
10 0
11 BIT?
12 SF 00
13 R↓
14 X<>Y
15 FS? 00
16 STO+ 00
17 -1
18 ROTXY
19 X<>Y
20 2
21 BASE÷
22 X>0?
23 GTO 00
24 RCL 00
25 END


42 XEQ ISQ -> 1764

Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Wanted: Efficient Algorithm to Square an Integer Number - Gerson W. Barbosa - 03-06-2019 11:47 PM



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