MCPcopy Create free account
hub / github.com/DentonW/DevIL / iSqrt

Function iSqrt

DevIL/src-IL/src/il_internal.cpp:227–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225};
226
227int iSqrt(int x) {
228 if (x >= 0x10000) {
229 if (x >= 0x1000000) {
230 if (x >= 0x10000000) {
231 if (x >= 0x40000000) {
232 return (table[x >> 24] << 8);
233 } else {
234 return (table[x >> 22] << 7);
235 }
236 } else if (x >= 0x4000000) {
237 return (table[x >> 20] << 6);
238 } else {
239 return (table[x >> 18] << 5);
240 }
241 } else if (x >= 0x100000) {
242 if (x >= 0x400000) {
243 return (table[x >> 16] << 4);
244 } else {
245 return (table[x >> 14] << 3);
246 }
247 } else if (x >= 0x40000) {
248 return (table[x >> 12] << 2);
249 } else {
250 return (table[x >> 10] << 1);
251 }
252 } else if (x >= 0x100) {
253 if (x >= 0x1000) {
254 if (x >= 0x4000) {
255 return (table[x >> 8]);
256 } else {
257 return (table[x >> 6] >> 1);
258 }
259 } else if (x >= 0x400) {
260 return (table[x >> 4] >> 2);
261 } else {
262 return (table[x >> 2] >> 3);
263 }
264 } else if (x >= 0) {
265 return table[x] >> 4;
266 }
267
268 //hm, x was negative....
269 return -1;
270}
271

Callers 1

Decompress3DcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected