I have the following Python snippet
v=(2*(a/2)+1)**2
U=int(((4*N+v)**.5-1)/4)
N is on the order of 10^12, and the variable "a" takes on many values but is also of 10^12 magnitude at its largest.
However I can't seem to write this in C++ without overflowing something somewhere and I am a little stuck.
edit: And yes, the 2*(a/2) is intentional because in Python, division is the same as floor division. Sometimes a is odd so I need to halve it, floor it, then remultiply it by 2, which is what that code does.
doubleand loose precission. The value ofvis in the range of 10^24, which is way higher than any integer that common platforms have