I need to find the nearest integer square root of a number between 0 and 0x10000 (65536 or 2^16). Capped at 0 and 0x100 (256). I need to do this thousands of times per frame! Using (int)Mathf.Sqrt(x) isn't going to cut it. It needs to be inline. Not a function call.
Obviously the easiest way is to create a byte array
and initialise it with all the square roots between 0..65536. e.g. with squareRoot[16]=4 up to squareRoot[0xFFFF] =...
Faster integer square root than this?
Obviously the easiest way is to create a byte array
Code (CSharp):
- byte[] squareRoot = new byte[65536];
Faster integer square root than this?