Math.GetBit
-----------

Queries a bit in a 64-bit number.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Math](component_Math.md) | [15.3](newinversion153.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Math.GetBit"; Value; Bit ) 

**MBS**( **"Math.GetBit";** /\* Queries a bit in a 64-bit number. \*/  
**$Value**; /\* The current value.e.g. 0 \*/   
**$Bit**) /\* The bit number to set.  
From 0 to 63.e.g. 0 \*/ 

### 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 ) &amp;   
MBS ( "Math.GetBit"; 123; 1 ) &amp;   
MBS ( "Math.GetBit"; 123; 2 ) &amp;   
MBS ( "Math.GetBit"; 123; 3 ) &amp;  
MBS ( "Math.GetBit"; 123; 4 ) &amp;  
MBS ( "Math.GetBit"; 123; 5 ) &amp;  
MBS ( "Math.GetBit"; 123; 6 ) &amp;  
MBS ( "Math.GetBit"; 123; 7 )  
<small>  
Example result: 11011110</small>Calculate Math.GetBit manually using shift and and:

 Let(\[  
 value = 123;  
 bitIndex = 3;  
 bit1 = MBS ("Math.GetBit"; value; bitIndex );  
 mask = MBS ("[Math.BitwiseShiftLeft](MathBitwiseShiftLeft.md)"; 1; bitIndex);  
 valueMasked = MBS ("[Math.BitwiseAND](MathBitwiseAND.md)"; value; mask);  
 bit2 = (valueMasked ≠ 0)  
\];  
bit1 &amp; ¶ &amp; bit2)  
<small>  
Example result:   
1  
1</small>### See also

- [Math.BitwiseAND](MathBitwiseAND.md)
- [Math.BitwiseShiftLeft](MathBitwiseShiftLeft.md)
- [Math.ClearBit](MathClearBit.md)
- [Math.SetBit](MathSetBit.md)

### Release notes

- **Version 15.3**
    - Added [Math.SetBit](https://www.mbsplugins.eu/MathSetBit.shtml), [Math.ClearBit](https://www.mbsplugins.eu/MathClearBit.shtml) and [Math.GetBit](https://www.mbsplugins.eu/MathGetBit.shtml) functions.

### Blog Entries

- [MBS FileMaker Plugin 15.3 News](https://www.mbsplugins.de/archive/2025-07-29/MBS_FileMaker_Plugin_153_News/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 15.3pr1](https://www.mbsplugins.de/archive/2025-06-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function is free to use.

Created 21st May 2025 , last changed 22nd May 2025

  
[Math.FormatNumber](MathFormatNumber.md) - [Math.HexToDec](MathHexToDec.md)

[HTML Version](MathGetBit.shtml)