This information is part of the Business Simulation Library (BSL). Please support this work and ► donate.
The output res corresponds to the binary bits of the input n shifted k places to the right.
Functions.intBitShiftRight(n); // k = 1 Functions.intBitShiftRight(n,k);
res := integer(n/2^k);
intBitShiftRight(10) ; // 5.0 intBitShiftRight(32,3); // 4.0
Negative values for k will shift to the left.
encapsulated function bitShiftRight import BusinessSimulation.Icons.Function; extends Function; input Integer n "Integer value whose binary bits are to be shifted"; input Integer k = 1 "Integer places to be shifted (default = 1)"; output Integer res "Integer value of the shifted bits"; end bitShiftRight;