INNER CODE UNIT · C

num

AmigaPorts/ACE · src/fixmath/fix16_sqrt.c:15

	uint32_t num = (neg ? -inValue : inValue);
	uint32_t result = 0;
	uint32_t bit;
	uint8_t  n;

	// Many numbers will be less than 15, so
	// this gives a good balance between time spent
	// in if vs. time spent in the while loop
	// when searching for the starting value.
	if (num & 0xFFF00000)
		bit = (uint32_t)1 << 30;
	else
		bit = (uint32_t)1 << 18;

	while (bit > num) bit >>= 2;

	// The main part is executed twice, in order to avoid
	// using 64 bit values in computations.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…