I'm writing a program which must take in an integer, N, in range 3<=N<=10^18. This is one of the operations I have to perform with N.
final=((0.5*(pow(2,0.5))*(pow((pow(((N/2)-0.5),2)+pow((N/2)-0.5,2)),0.5)))-0.5)*4;
N
is such that final
is guaranteed to contain an integer.
The problem is that I can't store N
in a float type as it is too large. If I store it in long long int, the answer is wrong(I think its because the intermediate value of N / 2
is then rounded off).