Android Question I need help with power arithmetic (2^3)

emexes

Expert
Licensed User
Longtime User
1674003994518.png


although if you're working with integers, probably simpler (and faster?) to just multiply it out manually ?
 
Upvote 0

emexes

Expert
Licensed User
Longtime User
B4X:
Dim P As Int = 1
For E = 1 To 3
    P = P * 2    'or P + P  ? 
Next

or if it's always base-2 then even better:

B4X:
P = Bit.ShiftLeft(1, 3)    'value of bit position 3 ie 2 ^ 3
 
Upvote 0
Top