Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - longshiftleft() shift left the bits in a ulong by the given number http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 longshiftleft()     Shift left the bits in a ulong by the given number
------------------------------------------------------------------------------
 Declaration
   bit.hdr

 Syntax
   func ulong longshiftleft extern
   param value ulong uNumber, ;
         value uint  uBits

 Arguments
   uNumber is a numeric expression.
   uBits is the number of bits to shift.

 Return
   The result of the shift operation.

 Description
   longshiftleft() shifts the 32 bits in uNumber to the left by the number
   specified by uBits. Rightmost bits are set to 0; bits "shifted out" are
   lost.

   When uNumber contains 7, its binary representation is

   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1

   longshiftleft( uNumber, 2 ) returns a result having the following binary
   representation:

   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0

   If uNumber has the following binary representation:

   1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 1 0 0 0 0 1 1 0 1 0

   longshiftleft( uNumber, 1 ) returns the following binary result:

   0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 1 0 0 0 0 1 1 0 1 0 0

   The leading "1" is lost.

 Example
   #define EXAMPLE_MATH
   #include example.hdr

   proc Test_longshiftleft
   vardef
      ulong nNum
      uint  n
   enddef
   // Multiply a ulong by 4
   nNum := 00000000000000000000000000000111B
   ? nNum                              // outputs  7
   ? longshiftleft( nNum, 2 )          // outputs 28
   ?
   nNum := 00000000000000000000000000000001B
   for n := 0 to 32
      ? n, longshiftleft( nNum, n )
   next
   endproc

   proc main
   Test_longshiftleft()
   endproc

See Also: longshiftright() shiftleft()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson