toexponential_用JavaScript中的示例对toExponential()方法进行编号

toexponential

Number toExponential()方法 (Number toExponential() Method)

toExponential() method is a method of Number class, it is used to convert a number into exponential notation format.

toExponential()方法是Number类的一种方法,用于将数字转换为指数符号格式。

Syntax:

句法:

    Number.toExponential([n]);

Here, n is an optional parameter, it is used to define the number of digits from 0 to 20 in the notation format.

此处, n是可选参数,用于以符号格式定义从0到20的位数。

Examples:

例子:

    Input: 10
    num = 123.456

    Function call:
    num.toExponential(15)

    Output:
    1.234560000000000e+2

Code:

码:

<html>
<head>
<title>JavaScipt Example</title>
</head>
<body>
<script>
	var num = 123.456;
	
	var exp_res1 = num.toExponential();
	var exp_res2 = num.toExponential(2);
	var exp_res3 = num.toExponential(15);
	
	document.write("exp_res1 = " + exp_res1 + "<br>");
	document.write("exp_res2 = " + exp_res2 + "<br>");
	document.write("exp_res3 = " + exp_res3 + "<br>");
	
</script>
</body>
</html>

Output

输出量

exp_res1 = 1.23456e+2
exp_res2 = 1.23e+2
exp_res3 = 1.234560000000000e+2


翻译自: https://www.includehelp.com/code-snippets/number-toExponential-method-with-example-in-javascript.aspx

toexponential

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值