gs gs128 Java Data Types Variables Arrays - Java BigDecimal - Quiz No.1
gs gs128 Java Quiz
This quiz belongs to book/course code gs gs128 Java of gs organization. We have 136 quizzes available related to the book/course Java. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Java Data Types Variables Arrays. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
double a = 0.02; double b = 0.03; double c = b - a; System.out.println(c); BigDecimal _a = new BigDecimal("0.02"); BigDecimal _b = new BigDecimal("0.03"); BigDecimal _c = b.subtract(_a); System.out.println(_c);
0.009999999999999998 0.01
0.01 0.009999999999999998
0.01 0.01
0.009999999999999998 0.009999999999999998
public class AddDemo { public static void main(String args[]) { BigDecimal b = new BigDecimal("23.43"); BigDecimal br = new BigDecimal("24"); BigDecimal bres = b.add(new BigDecimal("450.23")); System.out.println("Add: "+bres); MathContext mc = new MathContext(2, RoundingMode.DOWN); BigDecimal bdecMath = b.add(new BigDecimal("450.23"), mc); System.out.println("Add using MathContext: "+bdecMath); } }
Add: 473.66 Add using MathContext: 4.7E+2
Add 4.7E+2 Add using MathContext: 473.66