-
Notifications
You must be signed in to change notification settings - Fork 864
Open
Description
I am not sure if it is an issue with the Java version I am coding on, an Eclipse issue or code issue. When I run the code in Exercise_1_7, it outputs 4.0 as both outputs. I have to change all instances of 1 to 1.0 in the fractions, like this:
`public class Exercise_1_7 {
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(4 * ( 1.0 - (1.0 / 3) + (1.0 / 5) - (1.0 / 7) + (1.0 / 9) - (1.0 / 11)));
System.out.println(4 * ( 1.0 - (1.0 / 3) + (1.0 / 5) - (1.0 / 7) + (1.0 / 9) - (1.0 / 11) + (1.0 / 13)));
}
}`
My output is:
2.9760461760461765
3.2837384837384844
Metadata
Metadata
Assignees
Labels
No labels