ECMAScript operators. For more information about js learning, see 2.9.5. Addition operators.
Addition operators (plus signs and minus signs) are usually the simplest operators. However, in ECMAScript, each addition operator has many special behaviors.
1. Addition operators:
The Code is as follows:
Var iResult = 1 + 2;Console. log (iResult); // outputs 3
Special features:
The number of operations is NaN and the result is NaN.
Infinity and
In JavaScript, mathematical operations can be implemented in two different ways:
1.+ 、-、 *,/,% and other operators.2. Use the Math object's calculation function. For example, use Math.pow (2,3) to calculate 2 of the 3-time side.
Unlike Java, mathematical operations in JavaScript do not throw any errors. The overflow of the calculation, divided by 0, and the root of the negative numbers are all legal, and the result is a special value in javascript: positive and negative
()); "Ten"
Alert (num.tostring (9)); "One"
alert (num.tostring); A
3. Bitwise operators pay attention to Nan and infinity
When using bitwise operators for Nan and infinity, both values are treated as 0来. For non-numeric application bit operators, the number () function is used first to convert the value to a value.
One thing to note is that negative numbers are unsigned to the right, and the uns
relational operator--------");
Console.dir (16> "5");
Console.dir ("A" > "5");
Console.dir (5
Multiplication
Console.dir (5* "5");
Console.dir (5* "a");//nan
Console.dir (5*nan);//nan
Console.dir (5*null); 0
Console.dir (5* undefined);//nan
Console.dir (5*5);//25
Here are the multiplication implicit conversion principles:
1, if 2 numeric values are numbers, then direct multiplication, (I believe everyone will, and primary mathematics, as well as to pay attention to
cases, JavaScript will automatically convert the value into a scientific notation, and in other cases, it is represented directly in the literal form.
1. the number before the decimal point is 21 more digits.
console.log(1234567890123456789012);// 1.2345678901234568e+21 console.log(123456789012365648787); //123456789012365660000
2. The number of digits after the decimal point is greater than 5.
console.log(0.0000006);//6e-7 console.log(0.000006); //0.000006
Value Range
Due to memory limi
can use toString () to return any hexadecimal integer.
var num = 10;alert(num.toString()); //"10"alert(num.toString(9)); //"11"alert(num.toString(16)); //"a"
3. Pay attention to NaN and Infinity when using bitwise operators.
When the bitwise operator is used for NaN and Infinity, both values are treated as 0. If a bitwise operator is used for a non-numeric value, the Number () function is used to conver
. Don't be afraid. I try to make the language more popular. I hope this article will become a stepping stone for learning ECC.
1. Start with parallel lines.
Parallel lines. No one is skeptical. :) However, this conclusion has been questioned in modern times. Will parallel lines interwork in distant places? In fact, no one has ever seen it. So "parallel lines, never intersection" is just a hypothesis (we think about the parallel principle of junior high school learning, there is no proof ). Now t
Almost all systems running on supercomputers are Linux, including those made up of Raspberry Pi Raspberry and PlayStation 3 consoles.
Supercomputers are a serious tool, and they are all made up of tall calculations. They are often used for serious purposes, such as atomic bomb simulations, climate simulations, and advanced physics. Of course, they are also very expensive. In the latest supercomputer TOP500 rankings, China National Defense Univers
supports a variety of rendering APIs (such as Direct3D 9 and OpenGL), and by default all shader programs are compiled into all supported renderers. You can point out the shader that needs to be compiled by #pragma only_renderers or #pragma exclude_ renderers directive This is primarily useful in this case, you are explicitly using some material language features on some platforms that you know are impossible on some platforms
D3d9 -Direct3D 9.
D3d11 -Direct3D 11.
OpenGL -
1. Additionvarbox=1+2 //3varbox=1+nan//nan, one for Nan is NanvarBox=infinity+infinity//InfinityvarBox=-infinity +-infinity//-infinityvarBox=infinity +-infinity//Nan, positive
This article mainly introduces the mathematical operations in JavaScript. This article first explains some knowledge about mathematical operations, and then provides an example of operations. If you need a friend, you can refer to JavaScript, mathematical operations can be achieved through two operations:
1. +,-, *,/, %, and other operators.2. Use the computing functions of the Math object. For example, Math. pow (2, 3) is used to calculate the 3rd power of 2.
Unlike Java, mathematical operat
Introduction to mathematical operations in JavaScript and mathematical operations in javascript
In JavaScript, mathematical operations can be achieved through two operations:
1. +,-, *,/, %, and other operators.2. Use the computing functions of the Math object. For example, Math. pow (2, 3) is used to calculate the 3rd power of 2.
Unlike Java, mathematical operations in JavaScript do not throw any errors. The overflow, Division by 0, and opening of negative numbers are legal. The results are s
GetValue (left).
Let right explain the result of executing unaryexpression.
Make Rightvalue the GetValue (right).
Make Leftnum a Tonumber (leftvalue).
Make Rightnum a Tonumber (rightvalue).
Returns a specific operator (*,/, or%) Results that act on Leftnum and Rightnum
11.5.1 using the * operatorThe * operator represents multiplication and produces the product of the operand. The multiplication operation satisfies the commutative law. Because of the accuracy problem, mu
2.9.5. Addition OperatorsAddition operators (plus signs and minus signs) are usually the simplest operators. However, in ECMAScript, each addition operator has many special behaviors.1. Addition operators:Copy codeThe Code is as follows:Var iResult = 1 + 2;Console. log (iResult); // outputs 3 Special features:The number of operations is NaN and the result is NaN.Infinity and Infinity. The result is Infinity
2.JavaScriptJavaScript can only recognize integers (-2) from 53 to (2) 53.A. Numerical overflow:Data exceeds (2) 53 o'clock: expressed as infinity (positive infinity).Data is less than (-2) 53 o'clock: expressed as-infinity (negative infinity).B. Value underflow:The positive floating-point number is infinitely close t
In the previous minimum spanning tree problem encountered, I followed the previous habit of the INF defined as 1 billion, and then initialize the array to the maximum value, and then enter the connected path +value, the last value is still inf is not the case. But there is a problem here, the INF is defined as 1 billion, the last displayed array value is negative, finally changed to 0x3f3f3f3f finally solved.
Today just see a related blog, so carefully analysis.
Referenced from: http://blog.csdn
Several arithmetic operators are available in JavaScript, + (plus)-(minus) * (multiply)/(except)% (remainder), general usage is mathematically consistent, but special rules are also specified:Note: The way in which values are stored in JavaScript can be saved as positive 0 (+0) and negative 0 (-0), and positive zero and negative 0 are considered equal.Multiply sex operator (*):If the result is too large or too small, the resulting result is Infinity o
1. Infinity is infinitely smallBeginners should note that the infinity is the limit of 0 variables rather than the number 0, refers to the independent variable in a certain mode of change in the limit of 0, called a function is an infinite number, it is necessary to explain the change trend of the independent variable. For example, in the case of an infinite quantity, but not generally said to be infinitesi
This article from http://t.cn/zjyTuab
If the range of data in the problem is clear, the infinite setting is not a problem. If it is not clear, many programmers take 0x7fffffff as the infinite, because this is the maximum value of 32-bit Int. If this infinity is only used for general comparison (for example, the initial value of the min variable when the minimum value is obtained), 0x7fffffff is indeed a perfect choice, but in more cases, 0x7fffffff is
type, and the return value is not necessarily a Boolean value:
If one operation is an object and the other is a Boolean value, this object is returned.
If both operations are objects, the first object is returned.
If the number of operations is null, null is returned.
If the number of operations is NaN, NaN is returned.
An error occurs if the number of operations is undefined.
The logic OR in ECMAScript is also a simple operation. If the first operation determines the result, the second operati
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.