This content has been marked as final. Show 6 replies
I haveStart by turning those Strings into doubles.
String num = "123.33"
String num1 = "123.9"
if i want to display like
How can i do that?
Then use NumberFormat.
String num = "123.90"; double x = Double.valueOf(num); NumberFormat formatter = NumberFormat.getCurrencyInstance(); System.out.println(formatter.format(x));
is there any way to keep two decimal point without using double?You have no idea what you're doing. The number of decimal points should be purely a display condition. NumberFormat is the way to accomplish that.
If you don't understand how floating point numbers work, maybe you should read this: