Fuze Arena Logo
  • Forum
  • Creations
    Catalogue Showcase
  • Help

shiftLeft

Purpose

Bit shift left operator <<

Description

Shift all of the bits in a binary number to the left the specified number of times. The new rightmost bits are set to zero. Bitshift left has the effect of multipling the value of the binary number by 2

Syntax

result = number1 << number2

Arguments

number1 first binary number

number2 number of bits to shift

result resulting number with the bits of number1 shifted left number2 times

Example

loop
    textsize( 50 )
    byte1 = 123
    byte2 = 234
    printAt( 0, 0, "byte1 =         ", bin2str( byte1 ) )
    printAt( 0, 1, "byte2 =         ", bin2str( byte2 ) )
    printAt( 0, 2, "byte1 << 1 =    ", bin2str( byte1 << 1 ) )
    update()
repeat

function bin2str( byte )
    result = ""
    for i = 0 to 8 loop
        bit = byte & 1
        if bit then
            result = "1" + result
        else
            result = "0" + result 
        endIf
        byte = byte >> 1
    repeat
return result

Associated Commands

and, not, or, shiftLeft, shiftRight, xor

logo

©2019 FUZE Technologies Ltd. FUZE is a registered trademark of FUZE Technologies Ltd. All rights reserved.

Useful links

  • Fuze Main Site
  • Fuze Arena on Twitter
  • Fuze Arena on Youtube
  • Download Buyer

Contact Information

  • FUZE Technologies Ltd
    15 Clearfields Farm
    Wotton Underwood
    Aylesbury, Buckinghamshire
    ​England, HP18 0RS

  • +44 (0) 1844 239 432

  • contact@fuze.co.uk

© Copyright FUZE Technologies Ltd. All rights reserved.