so I've got some fairly large numbers to work with, and I need a way to calculate the square root of a given "long".
I cannot use Math.sqrt(x) as it is only for doubles
so I've got some fairly large numbers to work with, and I need a way to calculate the square root of a given "long".
I cannot use Math.sqrt(x) as it is only for doubles
You can extract one bit at a time, as demonstrated withthis C program: http://www.realitypixels.com/turk/opensource/index.html#FractSqrt This assumes that you have a fixed-point number with 30 fractional bits. If you have 0 fractional bits, then a 2N bit number would have an N bit square root, achieved by setting count to 15.