mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-24 10:01:38 +00:00
Merge pull request #2990 from adambard/bemusementpark-patch-1
Improve arithmetic output
This commit is contained in:
commit
61c8a08434
@ -312,7 +312,7 @@ public class LearnJava {
|
|||||||
System.out.println("2-1 = " + (i2 - i1)); // => 1
|
System.out.println("2-1 = " + (i2 - i1)); // => 1
|
||||||
System.out.println("2*1 = " + (i2 * i1)); // => 2
|
System.out.println("2*1 = " + (i2 * i1)); // => 2
|
||||||
System.out.println("1/2 = " + (i1 / i2)); // => 0 (int/int returns int)
|
System.out.println("1/2 = " + (i1 / i2)); // => 0 (int/int returns int)
|
||||||
System.out.println("1/2 = " + (i1 / (double)i2)); // => 0.5
|
System.out.println("1/2.0 = " + (i1 / (double)i2)); // => 0.5
|
||||||
|
|
||||||
// Modulo
|
// Modulo
|
||||||
System.out.println("11%3 = "+(11 % 3)); // => 2
|
System.out.println("11%3 = "+(11 % 3)); // => 2
|
||||||
|
Loading…
Reference in New Issue
Block a user