⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e313. formatting a number in exponential notation.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
The `E' symbol specifies that a number should be formatted in exponential notation. The symbol also separates the mantissa from the exponent. The symbol must be followed by one or more `0' symbols. The number of `0' symbols specifies the minimum number of digits used to display the exponent. 
    // Using only 0's to the left of E forces no decimal point
    NumberFormat formatter = new DecimalFormat("0E0");
    String s = formatter.format(-1234.567);  // -1E3
    
    formatter = new DecimalFormat("00E00");
    s = formatter.format(-1234.567);         // -12E02
    
    formatter = new DecimalFormat("000E00");
    s = formatter.format(-1234.567);         // -123E01
    
    formatter = new DecimalFormat("0000000000E0");
    s = formatter.format(-1234.567);         // -1234567000E-6
    
    
    // Force minimum number of digits to left and right of decimal point
    formatter = new DecimalFormat("0.0E0");
    s = formatter.format(-1234.567);         // -1.2E3
    
    formatter = new DecimalFormat("00.00E0");
    s = formatter.format(-1234.567);         // -12.35E2
    s = formatter.format(-.1234567);         // -12.35E-2
    
    
    // The number of #'s to the left of the decimal point (if any) specifies
    // the multiple of the exponent. The total number of #'s (left and right)
    // of the decimal point) specifies, the maximum number of digits to display
    formatter = new DecimalFormat("#E0");    // exponent can be any value
    s = formatter.format(-1234.567);         // -.1E4
    s = formatter.format(-.1234567);         // -.1E0
    
    formatter = new DecimalFormat("##E0");   // exponent must be multiple of 2
    s = formatter.format(-1234.567);         // -12E2
    s = formatter.format(-123.4567);         // -1.2E2
    s = formatter.format(-12.34567);         // -12E0
    
    formatter = new DecimalFormat("###E0");  // exponent must be multiple of 3
    s = formatter.format(-1234.567);         // -1.23E3
    s = formatter.format(-123.4567);         // -123E0
    s = formatter.format(-12.34567);         // -12.3E0
    s = formatter.format(-1.234567);         // -12.3E0
    s = formatter.format(-.1234567);         // -123E-3

 Related Examples 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -