I have a C# system using 160 bit numbers, stored in a BigInteger. I want to display these things on a circle, which means mapping the 0->2^160 range into the 0->2Pi range. How would I do this?
The approach that jumps instantly to mind is
BigInteger number;
angle = (number / pow(2, 160)) * TwoPi;
However, that has complexities because the division will truncate the result into an integer.
Ok, again, from the start.
Since your BigInteger is from 0 -> 2^160 it’s smaller than a double, which can contain from 10^(-308) to 10^(+308).
There is an explicit conversion from BigInteger to double.
So you do this:
I do know that you’ll lose precision, but that shouldn’t matter on the circle.