Quantcast
Channel: Unity Forum
Viewing all articles
Browse latest Browse all 1466670

Faster integer square root than this?

$
0
0
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

Code (CSharp):
  1. byte[] squareRoot = new byte[65536];
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?

Viewing all articles
Browse latest Browse all 1466670

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>