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

python - how we can use ajax() in views.py in django? -

matlab - Using loops to get multiple values into a cell -

python - Sequence Pattern recognition with Pybrain -