if you work with floating point numbers you can work seamlessly with primitive as double data type, but about those numbers have to perform operations must be very careful because it may not go the right results.
Why? Because computers work in binary and when working with variables of type float or double precision make mistakes when working with values that can not represent
How could it be otherwise, Java had already thought of this, and therefore provides BigDecimal, a class designed to solve these problems. But we still have a bad surprise in store.
The first thing to so one strip when using BigDecimal is the constructor BigDecimal (double), and this leads to the same problem. This constructor does is keep exactly the same representation as if working with a data type double. The solution is to work always with the constructor BigDecimal (String). BigDecimal's own documentation recommends it.
BigDecimal bd1 = new BigDecimal("8192.55");
in his case would be
BigDecimal bd = new BigDecimal(Float.toString((float) ((4.5 + 7.9) * 2))));
bd = bd.setScale(numberdecimals, BigDecimal.ROUND_HALF_UP);
//in his case would be considering whether to keep the number of decimal when zero
System.out.println(bd);