Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigDecimal;
- public class TestNumbers {
- public static void main(String[] args) {
- BigDecimal a1 = new BigDecimal(0.3);
- BigDecimal a11 = new BigDecimal("" + 0.3);
- double a2 = 0.3;
- float a3 = 0.3f;
- double b1 = 293.37;
- int a = (int) (a2 * 100);
- int b = (int) (b1 * 100);
- double c = a2 + a2 + a2;
- float f = (float) (c);
- float f2 = a3 + a3 + a3;
- BigDecimal d = a1.add(a1).add(a1);
- BigDecimal d2 = a11.add(a11).add(a11);
- double e = c / 100.0;
- System.out.println("a = " + a);
- System.out.println("b = " + b);
- System.out.println("c = " + c);
- System.out.println("f = " + f);
- System.out.println("f2 = " + f2);
- System.out.println("d = " + d);
- System.out.println("d2 = " + d2);
- System.out.println("e = " + e);
- System.out.println((0.3f + 0.3f + 0.3f));
- }
- }
Add Comment
Please, Sign In to add comment