float unitCost = 9.48f;
System.out.println("The unit cost is $" + unitCost);
BigDecimal fpValue = new BigDecimal(unitCost);
System.out.println("The float value is $" + fpValue);

Example 1: Using the float data type with monetary data.

Back to Article