summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndy <andrewgallasch@gmail.com>2015-10-31 19:39:26 +1030
committerAndy <andrewgallasch@gmail.com>2015-10-31 19:39:26 +1030
commit4593c65543eec73688acf999c4bab002116909b0 (patch)
treef06aad4dd5b320a7022aaf270d7389026654a3e2
parentedfc99e198fd2e87802ea81d6779fbadfab64919 (diff)
Improved int division comment and code
-rw-r--r--java.html.markdown4
1 files changed, 2 insertions, 2 deletions
diff --git a/java.html.markdown b/java.html.markdown
index 1813f81c..966aee15 100644
--- a/java.html.markdown
+++ b/java.html.markdown
@@ -207,8 +207,8 @@ public class LearnJava {
System.out.println("1+2 = " + (i1 + i2)); // => 3
System.out.println("2-1 = " + (i2 - i1)); // => 1
System.out.println("2*1 = " + (i2 * i1)); // => 2
- System.out.println("1/2 = " + (i1 / i2)); // => 0 (0.5 truncated down)
- System.out.println("1/2 = " + (i1 / (i2*1.0))); // => 0.5
+ System.out.println("1/2 = " + (i1 / i2)); // => 0 (int/int returns an int)
+ System.out.println("1/2 = " + (i1 / (double)i2)); // => 0.5
// Modulo
System.out.println("11%3 = "+(11 % 3)); // => 2