2^32
I was just wondering why the Prop can't calculate 2^32.
Answer should be 4,294,967,296
Gary Lake
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
pst : "Parallax Serial Terminal"
var
long t
long i
PUB main
pst.Start(115_200)
i := 2
t:=0
repeat 32
t++
pst.Dec(t)
pst.tab
pst.Dec(i)
pst.newline
i := i *2
pst.Str(string("All done!"))
Terminal window print out.
1 2
2 4
3 8
4 16
5 32
6 64
7 128
8 256
9 512
10 1024
11 2048
12 4096
13 8192
14 16384
15 32768
16 65536
17 131072
18 262144
19 524288
20 1048576
21 2097152
22 4194304
23 8388608
24 16777216
25 33554432
26 67108864
27 134217728
28 268435456
29 536870912
30 1073741824
31 -2147483648
32 0
All done!
Answer should be 4,294,967,296
Gary Lake
Comments
In binary the answer is
1_00000000_00000000_00000000_00000000
which is why you are getting zero. There will be an overflow flag somewhere.
Something like -- PHS bit 31 frequency = 80_000_000 x 322_122_547 / 2^32
A ** B = A* B / 2^32. Basically, it does multiplication of two 32-bit numbers into 64-bit number, and returns the higher 32 of those 64 bits
Something like -- PHS bit 31 frequency = 40_000_000 x 322_122_547 / 2^31
Duane
The A**B worked and the answer was 5,999,999
Thanks