java overflow during vector norm calculation with long -


I have 2 lengths to calculate the ideal of a 2dim vector: (example)

 < Code> tall x = 4294967296 L; Long y = 0 l; Long results; Result = (long) math. Square (x * x + y * y);   

My problem is that I have numbers so that they fit into X, Y and the result. But there is an overflow in computation of x * x and y * y.

Is there any easy way to avoid this or do I have to use BigInteger?

BigInteger should be your choice.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -