課程
/后端開發(fā)
/Java
/Java入門第三季
怎么將普通數(shù)字轉(zhuǎn)換為科學(xué)計(jì)數(shù)法,謝謝
2016-11-08
源自:Java入門第三季 3-4
正在回答
public static void parseSciNot(double num, double base, int index) {
? ? base = num;
? ? index = 0;
? ? if (num >= 1) {
? ? ???? while (base >= 10) {
????????????base = base / 10;
????????????index ++;
????????}
? ? }
? ? else {
? ? ???? while (base < 1) {
? ????? base = base * 10;
? ????? index --;
? ????? }
? ? System.out.println("The scientific notation of " + num + " is: " + base + "*10^(" + index + ")");
例如 3000=3*10的三次方。0.003=3*10的負(fù)三次方
舉報(bào)
Java中你必須懂得常用技能,不容錯(cuò)過的精彩,快來加入吧
2 回答course類型轉(zhuǎn)換
4 回答類型轉(zhuǎn)換異常
2 回答String類型到int類型的轉(zhuǎn)換
2 回答類型轉(zhuǎn)換問題
4 回答基本類型轉(zhuǎn)換
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-11-19
public static void parseSciNot(double num, double base, int index) {
? ? base = num;
? ? index = 0;
? ? if (num >= 1) {
? ? ???? while (base >= 10) {
????????????base = base / 10;
????????????index ++;
????????}
? ? }
? ? else {
? ? ???? while (base < 1) {
? ????? base = base * 10;
? ????? index --;
? ????? }
? ? }
? ? System.out.println("The scientific notation of " + num + " is: " + base + "*10^(" + index + ")");
? ? }
2016-11-08
例如 3000=3*10的三次方。0.003=3*10的負(fù)三次方