我是靠谱客的博主 曾经西装,最近开发中收集的这篇文章主要介绍javascript 数学_JavaScript中的数学常数,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

javascript 数学

Math in JavaScript is made easier by the language’s support for a series of mathematical constants. If it’s been a while since you’ve dealt with more than multiplication and division, I’ve also included a brief explanation of each in this article.

Java语言对一系列数学常数的支持使JavaScript中的数学变得更容易。 如果已经有一段时间了,因为您除了处理乘法和除法之外,还对本文的每一项进行了简要说明。

These JavaScript constants are all properties of the Math object. Note that, as constants, the properties are UPPERCASE, rather than the camelCase of most JavaScript.

这些JavaScript常数是Math对象的所有属性。 请注意,作为常量,属性是大写,而不是大多数JavaScript的camelCase。

数学PI (Math.PI)

Pi - popularly shortened to 3.14159 - is the circumference - that is, the outside perimeter - of a circle with diameter 1. For circles with a diameter greater or less than 1, we typically use the formula 2 × pi × r (The radius being exactly half the diameter, or the distance between the center of the circle and the perimeter).

Pi(通常缩写为3.14159)是直径为1的圆的圆周(即外周)。对于直径大于或小于1的圆,我们通常使用公式2×pi×r(半径为直径的一半,即圆心与周长之间的距离)。

Pi is irrational - it goes on forever and ever - and can never be expressed completely as a number, fraction, or decimal. Your browser can’t store an infinite number, so JavaScript shortens PI to 3.141592653589793, which is more than accurate enough for most purposes.

Pi是不合理的-它永远存在-永远不能完全用数字,分数或十进制表示。 您的浏览器无法存储无限数量,因此JavaScript会将PI缩短为3.141592653589793,对于大多数用途而言,它的准确性已经足够了。

While it’s most common application is finding the circumference and area of circles, pi is also used in probability, statistics, engineering and science: as a universal constant, it shows up everywhere.

尽管最常见的应用是查找圆的周长和面积,但是pi也用于概率,统计,工程和科学:作为一个普适常数,它随处可见。

数学SQRT2 (Math.SQRT2)

The square root of 2. Like pi, it is an irrational number; it is also the length of a diagonal across a square with sides of length 1. JavaScript approximates it to 1.4142135623730951. (Due to rounding errors, Math.SQRT2 * Math.SQRT2 is not exactly 2).

2的平方根。与pi一样,它是一个无理数; 它也是边长为1的正方形上对角线的长度。JavaScript将其近似为1.4142135623730951。 (由于舍入错误, Math.SQRT2 * Math.SQRT2不完全是2)。

数学SQRT1_2 (Math.SQRT1_2)

The square root of 0.5, equivalent to 1 divided by the square root of 2. Again, an irrational number.

0.5的平方根,等于1除以2的平方根。同样,这是一个无理数。

数学 (Math.E)

Ironically, in math the constant e is always lowercase: it’s only JavaScript that renders it uppercase. I’ll use the lowercase convention in this explanation.

具有讽刺意味的是,在数学中常数e始终是小写的:只有JavaScript使其大写。 在此说明中,我将使用小写字母约定。

e is also known as Euler’s number, and is the base of natural logarithms. Again, it is an irrational number: JavaScript approximates it as 2.718281828459045

e也称为欧拉数,是自然对数的底数。 同样,它是一个不合理的数字:JavaScript将其近似为2.718281828459045

e is the base rate of growth, a constant shared by every continually growing processes; compound interest, population growth, radioactive decay, and more. Examples of these processes are everywhere. Things grow at different rates over time, but they all share a commonality with e, which can be used as a “growth factor” in calculations. For example, a cell in a human embryo that divides and doubles continuously. In the console:

e是基本增长率 ,是每个持续增长的过程所共享的常数; 复利,人口增长,放射性衰变等。 这些过程的例子无处不在。 事物随时间以不同的速度增长,但是它们都与e共享一个共同点, e可以用作计算中的“增长因素”。 例如,人类胚胎中的细胞不断分裂和翻倍。 在控制台中 :

Math.pow(Math.E,1)
> 2.718281828459045

Math.pow(Math.E,2)
> 7.3890560989306495

Math.pow(Math.E,3)
> 20.085536923187664

自然对数 (Natural Logarithms)

The “natural” log is the inverse of e^x: rather than providing the amount of growth, the natural log (and its relations) provide the time needed to reach a certain level of growth. Math.log(x) provides the base e of a given number (x), but there are several built-in constants:

“自然”对数是e^x倒数 :自然对数(及其关系)不是提供增长量,而是提供达到一定增长水平所需时间Math.log(x)提供给定数字( x )的基数e ,但是有几个内置常量:

LN2数学 (Math.LN2)

The natural logarithm of 2. In JavaScript, rounded to 0.6931471805599453

JavaScript中的2的自然对数。四舍五入为0.6931471805599453

LN10数学 (Math.LN10)

The natural logarithm of 10: rounded to 2.302585092994046

10的自然对数:四舍五入为2.302585092994046

数学LOG2E (Math.LOG2E)

The base-2 logarithm of e. Rounded to 1.4426950408889634

e的以2为底的对数。 取整为1.4426950408889634

数学LOG10E (Math.LOG10E)

The base-10 logarithm of e. Rounded to 0.4342944819032518

e的以10为底的对数。 取整到0.4342944819032518

翻译自: https://thenewcode.com/1117/Math-Constants-in-JavaScript

javascript 数学

最后

以上就是曾经西装为你收集整理的javascript 数学_JavaScript中的数学常数的全部内容,希望文章能够帮你解决javascript 数学_JavaScript中的数学常数所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部