Kasun Athukorala wrote:why isn't it giving the same input value??
Because double only has 64 bit to store its information. Your number is too large and it gets truncated.
How can i get the same output as the input??
By using BigDecimal. That's the only data type in Java that's accurate enough. Note that you should use the constructor that takes a String; don't create one from a double because the truncation will then happen before the BigDecimal is created.