类型转换

来源:3-4 Java 中基本类型和字符串之间的转换

cute倩影O_o

2016-11-08 21:26

怎么将普通数字转换为科学计数法,谢谢

写回答 关注

2回答

  • 绿色蝈蝈拜见
    2016-11-19 16:36:29

    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 22:51:27

    例如 3000=3*10的三次方。0.003=3*10的负三次方

Java入门第三季

Java中你必须懂得常用技能,不容错过的精彩,快来加入吧

409781 学习 · 4339 问题

查看课程

相似问题