09-08-2022, 03:54 AM
(09-05-2022, 07:23 PM)Kernelpanic Wrote: Good job again! Nullo problemo!^
The bit rotations are similar to the shift operators, where is the concrete difference?
Code: (Select All)'Uebung mit Bitrotation - 5. Sept. 2022
'Aehnelt den Schiebeoperatoren
Dim As Long a, b
Input "a: ", a
Input "b: ", b
'Verschiebt 1 Bit nach rechts. Entspricht: Zahl / 2
a = _RoR(a, 1)
Print a
'Verschiebt nach links. Entspricht: Zahl * 2
b = _RoL(b, 1)
Print b
'Vierfach des letzten Wertes (b X 4)
b = _RoL(b, 2)
Print b
End
|
Try rewriting this program so it uses "_BIN$()", with zero-padding at front so you could see better what's going on. Do at least 32 interations and one bit at a time for an _INTEGER64.
Or otherwise:
Code: (Select All)
$console:only
dim c as _unsigned _integer64
dim as string see, zer
dim i as integer
zer = string$(64, 48)
c = 9223372036854775810
print c
for i = 1 to 65
see = _bin$(c)
see = "&B" + left$(zer, 64 - len(see)) + see
print see
c = _ROL(c, 1)
next
system