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
Post a Comment