Possible loss of precision

Before i can make this code into a method i have to fix this error: Possible loss of precision, found double. Required long

value = (Math.pow(-1, terms) * Math.pow(radAngle, (2*terms))) / factorial((2 * terms))); // inside a for loop in the main {}

terms changes because its inside a for loop, 1 - 11 terms, rad angle is the input by the user, and factorial calls the method.

The way this works out is Double * double / long = long. I get precision errors. Now if my answer is a long how can it be in decimal form? it recommends i cast the doubles and write and write (long) in front of both doubles. The numbers i'm computing are going to have ALOT of decimal places. What do i do? I've never ran into this problem and thought i could easily do Double / Long.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories