.BusinessSimulation.Functions.bitShiftRight

Information

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.

Syntax


Functions.intBitShiftRight(n);  // k = 1
Functions.intBitShiftRight(n,k);

Implementation


res := integer(n/2^k);

Examples


intBitShiftRight(10)  ; // 5.0
intBitShiftRight(32,3); // 4.0

Notes

Negative values for k will shift to the left.

Interface

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;

Revisions


Generated at 2024-11-20T19:25:51Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos