In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you the relevant knowledge of how to calculate exponentiation in javascript. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.
Javascript to calculate the power of the method: 1, the use of Math object pow () method, syntax "Math.pow (n, m)", can return the value of the m power of n; 2, the use of the power operator "*", syntax "x * * y", can return the value of the y power of x.
The operating environment of this tutorial: windows7 system, javascript1.8.5 version, Dell G3 computer.
Exponentiation operation
Power (power) is the result of exponential operation. When m is a positive integer, n means that the expression means the multiplication of m n. When m is a decimal, m can be written as a prime b (where an and b are integers), and n "means n" and then open the root sign b times.
When m is an imaginary number, it is necessary to use the Euler formula ei θ = cos θ + isin θ, and then use the logarithmic property to solve the problem.
Think of n times as the result of the power, which is called the m power of n, also known as the m power of n.
How to calculate the exponentiation of javascript
Method 1: use the pow () method
The pow () method returns the value of n to the power of m. If the result is imaginary or negative, the method returns NaN. If a floating-point overflow occurs because the index is too large, the method returns Infinity.
Example: returns the value of 4 to the third power (4 / 4 / 4)
Console.log (Math.pow (4,3))
Method 2: use the exponentiation operator (*)
The power operator (* *) returns the first Operand as the base and the second Operand as the multiplier of the exponent. It is equivalent to Math.pow, except that it also accepts BigInts as an Operand.
Console.log (3 * * 4); / / expected output: 81console.log (10 * *-2); / / expected output: 0.01console.log (2 * * 3 * 2); / / expected output: 512console.log ((2 * * 3) * * 2); / / expected output: 64
These are all the contents of the article "how to calculate the exponentiation of javascript". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.