I have a application which reads SAS xpt file and stores column value into ByteBuffer
and then using getValue()
method of it to get Double object. Now I have to print Double
upto 12 significant digit after decimal. I found one answer from this from which is working fine but few cases
BigDecimal bd = new BigDecimal(dblColumnData.doubleValue());
System.out.println(String.format("%."+15+"G", bd));
Here 15 is given because there are 3 digits in integer part and there must be 12 significant digit after decimal.
Cases where it is not working is because BigDecimal
created from Double
. If I print Double then it contains more than 12 digits after decimal and it round correctly with same above approach.
Therefore I think if I can get similar format method for Double
the it will solve my problem.