03-11-2024, 04:34 AM
Ok, I reworked the code and multiplying is definitely faster. Thanks for the insight DSMan195276.
Code: (Select All)
DIM x AS INTEGER
DIM y AS INTEGER
DIM i AS LONG
DIM t AS DOUBLE
DIM t1 AS DOUBLE
DIM t2 AS DOUBLE
x = 4
DO
i = 0
t = TIMER(.001)
DO
y = x * 4
i = i + 1
LOOP UNTIL i = 1000000000 ' a billion times
t1 = TIMER(.001) - t
i = 0
t = TIMER(.001)
DO
y = _SHL(x, 2)
i = i + 1
LOOP UNTIL i = 1000000000
t2 = TIMER(.001) - t
BEEP
CLS
PRINT
PRINT USING " #.### --> Multiplying"; t1
PRINT USING " #.### --> Shiting left"; t2
LOOP