How Can I format a double with full precision?
Basically I want to get those format :
FullPrecisionNumericConverter converter = new FullPrecisionNumericConverter();
Double number = 1234567.8901234567d; // full precision of double is 17 digits
String amount = converter.toString(number);
String expected = "1,234,567.8901234567";
assertEquals(expected, amount);
number = -1234567.8901234567d;
amount = converter.toString(number);
expected = "-1,234,567.8901234567";
assertEquals(expected, amount);
number = 12.89;
amount = converter.toString(number);
expected = "12.89";
assertEquals(expected, amount);
Thanks!
Aucun commentaire:
Enregistrer un commentaire