@technobuddha > library > Binary > Arithmetic
Function: maj()
ts
function maj(
x: number,
y: number,
z: number): number;Defined in: maj.ts:14
Computes the majority function of three numbers.
For each bit position, returns the value that is present in at least two of the three inputs. This is commonly used in cryptographic hash functions such as SHA.
Parameters
| Parameter | Type | Description |
|---|---|---|
x | number | The first input number. |
y | number | The second input number. |
z | number | The third input number. |
Returns
number
The majority value for each bit position among the three inputs.