課程
/后端開發
/Java
/Java入門第三季
怎么將普通數字轉換為科學計數法,謝謝
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的負三次方
舉報
Java中你必須懂得常用技能,不容錯過的精彩,快來加入吧
2 回答course類型轉換
4 回答類型轉換異常
2 回答String類型到int類型的轉換
2 回答類型轉換問題
4 回答基本類型轉換
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
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的負三次方