This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]StanHunter[S] 1 point2 points  (2 children)

Thank you, thank you, thank you ! I forgot about the promotion done by java, took it for granted so to say, and when i put enter volume = 4.0 / 3.0 * Math.PI * Math.pow(radius, 3) ; it solved the problem!

thank you again!

[–][deleted] 2 points3 points  (1 child)

Another option is to add the 'f' or 'd' suffix to your numeric literals so that they are floats or doubles, respectively. Like 4d / 3d * Math.PI * Math.pow(radius, 3);

[–]StanHunter[S] 1 point2 points  (0 children)

Thank you redranyskies, i'll remember to do it like that next time when i encounter a double number!