Rotating and shifting bits – Texas Instruments PLUS TI-89 User Manual

Page 365

Advertising
background image

348 Chapter 20: Number Bases

20NUMBAS.DOC TI-89/TI-92 Plus: Number Bases (English) Susan Gullord Revised: 02/23/01 1:17 PM Printed: 02/23/01 2:19 PM Page 348 of 6

Function with syntax

Description

rotate(

integer

)

– or –

rotate(

integer

,

#ofRotations

)

If

#ofRotations

is:

¦

omitted — bits rotate once to the
right (default is ë 1).

¦

negative — bits rotate the specified
number of times to the right.

¦

positive — bits rotate the specified
number of times to the left.

In a right rotation, the rightmost bit
rotates to the leftmost bit; vice versa for
a left rotation.

shift(

integer

)

– or –

shift(

integer

,

#ofShifts

)

If

#ofShifts

is:

¦

omitted — bits shift once to the right
(default is ë 1).

¦

negative — bits shift the specified
number of times to the right.

¦

positive — bits shift the specified
number of times to the left.

In a right shift, the rightmost bit is
dropped and 0 or 1 is inserted to match
the leftmost bit. In a left shift, the
leftmost bit is dropped and 0 is inserted
as the rightmost bit.

Suppose you enter:

shift(0h7AC36)

Internally, the hexadecimal
integer is converted to a signed,
32-bit binary number.

Then the shift is applied to the
binary number.

If Base mode = HEX:

If Base mode = BIN:

0h7AC36 = 0b00000000000001111010110000110110

0b00000000000000111101011000011011 = 0h3D61B

The result is displayed according to the

Base

mode.

Rotating and
Shifting Bits

Note: You can select these
functions from the
MATH

/Base

menu. For an

example using each
function, refer to Appendix A
in this book.

Note: If you enter an integer
that is too large to be stored
in a signed, 32-bit binary
form, a symmetric modulo
operation brings the value
into the range (page 346).

Leading zeros are not shown
in the result.

Inserts 0 if leftmost bit is 0,

or 1 if leftmost bit is 1.

Each bit shifts to the right.

Dropped

Advertising
This manual is related to the following products: