iPXE
Functions
isqrt.h File Reference

Integer square root. More...

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
 FILE_SECBOOT (PERMITTED)
 
unsigned long isqrt (unsigned long value)
 Find integer square root. More...
 

Detailed Description

Integer square root.

Definition in file isqrt.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED  )

◆ isqrt()

unsigned long isqrt ( unsigned long  value)

Find integer square root.

Parameters
valueValue
isqrtInteger square root of value

Definition at line 41 of file isqrt.c.

41  {
42  unsigned long result = 0;
43  unsigned long bit = ( 1UL << ( ( 8 * sizeof ( bit ) ) - 2 ) );
44 
45  while ( bit > value )
46  bit >>= 2;
47  while ( bit ) {
48  if ( value >= ( result + bit ) ) {
49  value -= ( result + bit );
50  result = ( ( result >> 1 ) + bit );
51  } else {
52  result >>= 1;
53  }
54  bit >>= 2;
55  }
56  return result;
57 }
static unsigned int unsigned int bit
Definition: bigint.h:392
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
uint16_t result
Definition: hyperv.h:33

References bit, result, and value.

Referenced by math_test_exec(), and profile_stddev().