Skip to content

Instantly share code, notes, and snippets.

@garrettwilkin
Created October 5, 2012 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garrettwilkin/3840376 to your computer and use it in GitHub Desktop.
Save garrettwilkin/3840376 to your computer and use it in GitHub Desktop.
Java double experiments.
gw@airy ~/> java Reps
a: 1.0
b: 0.35
c: 0.65
d: 0.35
e: 0.035
f: 0.034999999999999996
g: 0.06999999999999999
This java class:
public class Reps {
public static void main(String[] args) {
double a = 1.0;
System.out.println("a: "+a);
double b = a - 0.65;
System.out.println("b: "+b);
double c = a * 0.65;
System.out.println("c: "+c);
double d = 35.0 / 100.0;
System.out.println("d: "+d);
double e = 35.0 / 1000.0;
System.out.println("e: "+e);
double f = 0.70 * 0.05;
System.out.println("f: "+f);
double g = f * 2.0;
System.out.println("g: "+g);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment