Hi Every body!!
I'm learning java this semester, I have a C/C++ background so sometimes things get a litter bit confusing in here, hopefully I learn the very basis soon :-)
I'm working with a method that accept a double without format, it might looks something like this 14564852.51654874659765456874684639786514356452364 or 784643213218432516548468486.3 and the method must forma it to a two decimal number rounding it up (14564852.52 or 784643213218432516548468486.30)
this is how I code this method
public double formatMoney(double money) { double money_formatted = 0.00; if (money >= 0) { BigDecimal formatted_1 = new BigDecimal(money); MathContext format = new MathContext(2, RoundingMode.CEILING); formatted_1.round(format); money_formatted = formatted_1.doubleValue(); System.out.println(formatted_1);//<-----------------in here I'm getting a big number that I don't know where come from } return money_formatted; }
I'll appreciate any input that any of you can give me!
have a nice day!