From 4593c65543eec73688acf999c4bab002116909b0 Mon Sep 17 00:00:00 2001 From: Andy Date: Sat, 31 Oct 2015 19:39:26 +1030 Subject: Improved int division comment and code --- java.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'java.html.markdown') 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 -- cgit v1.2.3