.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-12-21T19:25:56Z by OpenModelicaOpenModelica 1.24.3 using GenerateDoc.mos