Advertisement
Sim0o0na

Double precision example

Jun 19th, 2019
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. package com.company;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. double f1 = .0;
  7. for (int i = 1; i <= 11; i++) {
  8. f1 += 0.1;
  9. }
  10.  
  11. System.out.println(f1);
  12. String numFormatted = String.format("%.2f", f1);
  13. System.out.println(numFormatted);
  14. f1 = Double.parseDouble(numFormatted);
  15. System.out.println(f1);
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement