第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

請問用科學(xué)計(jì)數(shù)法格式化雙值

請問用科學(xué)計(jì)數(shù)法格式化雙值

鳳凰求蠱 2019-11-03 13:04:54
我有一個類似的雙精度數(shù)字223.45654543434,我需要把它顯示為0.223x10e+2。如何用Java做到這一點(diǎn)?
查看完整描述

3 回答

?
縹緲止盈

TA貢獻(xiàn)2041條經(jīng)驗(yàn) 獲得超4個贊

您可以使用java.text包以科學(xué)計(jì)數(shù)法顯示數(shù)字。專門DecimalFormat針對java.text包裝的類可用于此目的。


以下示例顯示了如何執(zhí)行此操作:


import java.text.*;

import java.math.*;


public class TestScientific {


  public static void main(String args[]) {

     new TestScientific().doit();

  }


  public void doit() {

     NumberFormat formatter = new DecimalFormat();


     int maxinteger = Integer.MAX_VALUE;

     System.out.println(maxinteger);    // 2147483647


     formatter = new DecimalFormat("0.######E0");

     System.out.println(formatter.format(maxinteger)); // 2,147484E9


     formatter = new DecimalFormat("0.#####E0");

     System.out.println(formatter.format(maxinteger)); // 2.14748E9



     int mininteger = Integer.MIN_VALUE;

     System.out.println(mininteger);    // -2147483648


     formatter = new DecimalFormat("0.######E0");

     System.out.println(formatter.format(mininteger)); // -2.147484E9


     formatter = new DecimalFormat("0.#####E0");

     System.out.println(formatter.format(mininteger)); // -2.14748E9


     double d = 0.12345;

     formatter = new DecimalFormat("0.#####E0");

     System.out.println(formatter.format(d)); // 1.2345E-1


     formatter = new DecimalFormat("000000E0");

     System.out.println(formatter.format(d)); // 12345E-6

  }

}  



查看完整回答
反對 回復(fù) 2019-11-04
  • 3 回答
  • 0 關(guān)注
  • 699 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號