<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>
In Math Words in 32-bit library
Performs a logical shift of the double value x right by count bits, yielding the double value y.
-3200. DABS 5 D>> DNEGATE D. (displays -100) 3200. 5 D>> D. (displays 100) -3200. 5 D>> D. (displays 134217628)
-3200. DABS 5 D>> DNEGATE D.
3200. 5 D>> D.
-3200. 5 D>> D.
The value x halves with each shift. Zeros are shifted in from the most significant bit, meaning the sign of the value could change. Note that count is a single value, not a double.
Care should be taken when shifting signed values (or rather, values that are to be interpreted as signed values) since the sign of the value (as dictated by the most significant bit) may change as a result of the shift.