本文共 1374 字,大约阅读时间需要 4 分钟。
Math operations in JavaScript are handled using functions of math library in JavaScript. In this tutorial on Math.log2() method, we will learn about the log2() method and its working with examples.
JavaScript中的数学运算是使用JavaScript中的数学库函数处理的。 在有关Math.log2()方法的本教程中,我们将学习log2()方法及其示例。
JavaScript has multiple methods in its math library to support mathematical operations in JavaScript.
JavaScript在其数学库中有多种方法来支持JavaScript中的数学运算。
Math.log2() method in JavaScript is inbuilt. This function returns the value of the logarithmic value of base 2 of the number.
JavaScript中的Math.log2()方法是内置的。 此函数返回数字以2为底的对数值的值 。
Syntax:
句法:
Math.log2(n);
Parameter(s):
参数:
n – It takes only one value which is the number whose logarithm is to be found.
n –仅采用一个值,该值是要找到其对数的数字。
Return value:
返回值:
The return type of this method is number, it returns the log2 of the given number.
该方法的返回类型为number ,它返回给定数字的log 2 。
Example 1: finding the log of an integer.
示例1:查找整数的对数。
Page Title
Output
输出量
Example 2: finding log of a string.
示例2:查找字符串的日志。
Page Title
Output
输出量
When a string is passed to the log2() method. It returns NaN denoting the passed value is not a number.
将字符串传递给log 2 ()方法时 。 它返回NaN表示传递的值不是数字。
Example 3: Find the log of a complex number.
示例3:查找复数的日志。
Page Title
Output
输出量
Invalid or unexpected token
翻译自:
转载地址:http://zwvzd.baihongyu.com/