Skip to content

@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 ​

ParameterTypeDescription
xnumberThe first input number.
ynumberThe second input number.
znumberThe third input number.

Returns ​

number

The majority value for each bit position among the three inputs.