7. 本日のメイントピック
Java Puzzlers
in
Google I/O 2011
6
Advanced Tech Night
8. 1. ウォーミングアップ
public static void main(String args[]) {
System.out.println(2.00 - 1.10);
}
a) 0.90
b) 0.9
c) 1
d) その他
7
Advanced Tech Night
9. 1. ウォーミングアップ(回答)
public static void main(String args[]) {
System.out.println(2.00 - 1.10);
}
出力結果)
0.8999999999999999
8
Advanced Tech Night
10. 2. おつりの計算
import java.math.BigDecimal;
public class Change {
public static void main(String args[]) {
BigDecimal payment = new BigDecimal(2.00);
BigDecimal cost = new BigDecimal(1.10);
System.out.println(payment.subtract(cost));
}
}
a) 0.90
b) 0.9
c) 1
d) その他
9
Advanced Tech Night
11. 2. おつりの計算(回答)
import java.math.BigDecimal;
public class Change {
public static void main(String args[]) {
BigDecimal payment = new BigDecimal(2.00);
BigDecimal cost = new BigDecimal(1.10);
System.out.println(payment.subtract(cost));
}
}
出力結果)
0.899999999999999911182158029987476766109466552734375
10
Advanced Tech Night