double a = 10.0;
double b =3;
double c = a/b;
System.out.println(c*b);//answer = 10.0
BigDecimal bigDecimal1 = BigDecimal.valueOf(c);
BigDecimal bigDecimal2 = new BigDecimal("3");
System.out.println(bigDecimal1.multiply(bigDecimal2));//answer = 10.0000000000000005
I'm trying to make a calculator, but there's a problem with 10/3*3 I don't want to just calculate 10/3*3 this formula, I want to return this formula plus 0.2323232323232 of the float. So use the BigDecimal class. There's something wrong with it I couldn't get the exact result, that's what I wanted 10, Rather than get 10.0000000000000005