This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
In my code there is a problem with a double number and I don't know how to solve that
Here is the method where the problem comes from:
So, in here
gives the value 0.0 whatever the values of x and y. Even if the value of y is 350 heightPixel =0.0. Can anyone help where the problem come from? =/ and second question how to make double to be value with 6 decimal places not only 2 as in this case? Cheers
The reason is simple. You are doing some division operations before doing round operation.
Hint : a/b = 0 when a and b are int and a < b.
I hope this helps.
Thank you so much! But shouldn't double be to 14 decimal points by default ? why it is only to 2? and OK it could be 0 between 0-699 but why when x=700 it is not 1 still 0?=/
Thanks for your answer by the way I get where I did have a mistake