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)
 
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  )

◆ isqrt()

unsigned long isqrt ( unsigned long  value)

Find integer square root.

Parameters
valueValue
isqrtInteger square root of value

Definition at line 40 of file isqrt.c.

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

References bit, result, and value.

Referenced by math_test_exec(), and profile_stddev().