| Components | All | New | MacOS | Windows | Linux | iOS | ||||
| Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old | |
Math.ClearBit
Clears a bit in a 64-bit number.
| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
| Math | 15.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
MBS( "Math.ClearBit"; Value; Bit ) More
Parameters
| Parameter | Description | Example |
|---|---|---|
| Value | The current value. | 0 |
| Bit | The bit number to set. From 0 to 63. |
0 |
Result
Returns OK or error.
Description
Clears a bit in a 64-bit number.Examples
Clear 1st bit, which removes 1 from 5:
MBS( "Math.ClearBit"; 5; 0 )
Example result: 4
Example result: 4
Clear 2nd bit, which does nothing here:
MBS( "Math.ClearBit"; 5; 1 )
Example result: 5
Example result: 5
Clear 3rd bit, which removes 4:
MBS( "Math.ClearBit"; 5; 2 )
Example result: 1
Example result: 1
Try function:
Let([
v1 = 16;
r = MBS("Math.GetBit"; v1; 4);
v2 = MBS("Math.SetBit"; v1; 5);
v3 = MBS("Math.ClearBit"; v2; 5)
];
"Value before: " & v1 & ¶ &
"Bit 4 is set? " & r & ¶ &
"Value with bit 5 set: " & v2 & ¶ &
"Value with bit 5 cleared: " & v3)
Example result:
Value before: 16
Bit 4 is set? 1
Value with bit 5 set: 48
Value with bit 5 cleared: 16
v1 = 16;
r = MBS("Math.GetBit"; v1; 4);
v2 = MBS("Math.SetBit"; v1; 5);
v3 = MBS("Math.ClearBit"; v2; 5)
];
"Value before: " & v1 & ¶ &
"Bit 4 is set? " & r & ¶ &
"Value with bit 5 set: " & v2 & ¶ &
"Value with bit 5 cleared: " & v3)
Example result:
Value before: 16
Bit 4 is set? 1
Value with bit 5 set: 48
Value with bit 5 cleared: 16
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 29th June 2025