How to prevent floats and doubles from getting truncated in Java

1 Answer

0 votes
import java.math.BigDecimal;

public class JavaApplication {
 
    public static void main(String[] args) {
 
        BigDecimal bd = new BigDecimal("87155829374.5600820123");

        System.out.println(bd);
    }
}
  
  
  
/*
run:
  
87155829374.5600820123
  
*/

 



answered Jun 1, 2024 by avibootz

Related questions

1 answer 185 views
1 answer 195 views
1 answer 284 views
1 answer 884 views
884 views asked Aug 21, 2019 by avibootz
1 answer 256 views
1 answer 301 views
...