ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 12.06.2025
Просмотров: 8254
Скачиваний: 1
© MCS Electronics, 1995-2007
For values <0, -1 will be returned
For 0, 0 will be returned
For values >0, 1 will be returned
See Also
INT , FIX , ROUND
Example
Dim S As Single , X As Single , Y As Single
X = 2.3 : S = Sgn(x)
Print S
X = -2.3 : S = Sgn(x)
Print S
End
SHIFT
Action
Shift all bits one place to the left or right.
Syntax
SHIFT var , LEFT/RIGHT[ , shifts]
Remarks
Var |
Byte, Integer/Word, Long or Single variable. |
Shifts |
The number of shifts to perform. |
The SHIFT statement rotates all the bits in the variable to the left or right.
When shifting LEFT the most significant bit, will be shifted out of the variable. The LS bit becomes zero. Shifting a variable to the left, multiplies the variable with a value of two.
When shifting to the RIGHT, the least significant bit will be shifted out of the variable. The MS bit becomes zero. Shifting a variable to the right, divides the variable by two.
A Shift performs faster than a multiplication or division.
See also
ROTATE , SHIFTIN , SHIFTOUT
Example
'----------------------------------------------------------------------------- |
|
------------ |
: shift.bas |
'name |
|
'copyright |
: (c) 1995-2005, MCS Electronics |
'purpose |
: example for SHIFTIN and SHIFTOUT statement |
'micro |
: Mega48 |
'suited for demo |
: yes |
'commercial addon needed |
: no |
page -647- |