Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
Math.GetBit
Queries a bit in a 64-bit number.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
Math | 15.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
Parameters
Parameter | Description | Example |
---|---|---|
Value | The current value. | 0 |
Bit | The bit number to set. From 0 to 63. |
0 |
Result
Returns number or error.
Description
Queries a bit in a 64-bit number.Returns 1 if bit is set or 0 if not.
Examples
Query first 8 bits:
MBS( "Math.GetBit"; 123; 0 ) &
MBS( "Math.GetBit"; 123; 1 ) &
MBS( "Math.GetBit"; 123; 2 ) &
MBS( "Math.GetBit"; 123; 3 ) &
MBS( "Math.GetBit"; 123; 4 ) &
MBS( "Math.GetBit"; 123; 5 ) &
MBS( "Math.GetBit"; 123; 6 ) &
MBS( "Math.GetBit"; 123; 7 )
Example result: 11011110
Calculate Math.GetBit manually using shift and and:
Let([
value = 123;
bitIndex = 3;
bit1 = MBS("Math.GetBit"; value; bitIndex );
mask = MBS("Math.BitwiseShiftLeft"; 1; bitIndex);
valueMasked = MBS("Math.BitwiseAND"; value; mask);
bit2 = (valueMasked ≠ 0)
];
bit1 & ¶ & bit2)
Example result:
1
1
See also
Release notes
- Version 15.3
- Added Math.SetBit, Math.ClearBit and Math.GetBit functions.
Blog Entries
This function is free to use.
Created 21st May 2025, last changed 22nd May 2025
