double aDouble = 12345678912345678912345.0; BigDecimal dd = new BigDecimal(aDouble); System.out.println(dd); // print: 12345678912345679593472 String aString = "12345678912345678912345.0"; BigDecimal bd = new BigDecimal(aString); System.out.println(bd); // print: 12345678912345678912345.0 Java Hangs When Converting 2.2250738585072012e-308 - http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/ http://bugs.openjdk.java.net/show_bug.cgi?id=100119 Compare performance between double and float - http://www.heatonresearch.com/content/choosing-between-java%E2%80%99s-float-and-double How to work correctly with double - http://vanillajava.blogspot.com.au/2014/07/compounding-double-error.html Maybe handy api, Math.toIntExact(Long) - http://marxsoftware.blogspot.com/2018/06/exact-conversion-of-long-to-int-in-java.html Check the border cases - http://vanillajava.blogspot.com.au/2015/02/inconsistent-operation-widen-rules-in.html http://vanillajava.blogspot.com.au/2014/10/a-java-conversion-puzzler-not-suitable.html