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
Transfer from http://aikilis.tk/
If the scope of the data in the problem is clear, then the infinite setting is not a problem, in the ambiguous case, many programmers take 0x7fffffff as infinity, because this is the maximum value of 32-bit int. If this infinity is used only for general comparisons (such as the initial value of the min variable at the minimum), then 0x7fffffff is a perfect choice, but in mor
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 corresponding variable has saved a reference to an objectThe value of the undefined that is derived from the null value.The equality operator (true) between undefined and null is the main purpose: to convert its operandsUndefined when there is no need to display a variable, and there is no time to initialize obj, the computer givesBoolean:true (not necessarily 1), false (not necessarily 0)var t1=true;var F1=false;Use the Boolean (obj) function to cast obj to a Boolean value, and the returne
Original: Learn JavaScript from the beginning (v)--operator (ii)One, multiplicative sex operator1. Multiplication: *Some special rules for multiplication operators:
If the operand is a numeric value, it is calculated by normal multiplication, and if the product exceeds the representation range of the ECMAScript value, it returns infinity or-infinity
If one of the operands is Nan, the return res
One, multiplicative sex operator1. Multiplication: *Some special rules for multiplication operators:
If the operand is a numeric value, it is calculated by normal multiplication, and if the product exceeds the representation range of the ECMAScript value, it returns infinity or-infinity
If one of the operands is Nan, the return result is Nan
If infinity
shipment count is NULL, return null
If a shipping count is Nan, return nan
If an op count is undefined, an error occurs.
The logical or in the ECMAScript is also a simple operation, that is, if the first operand determines the result, the second operand is no longer computed, and the example:
Copy Code code as follows:
var btrue=true;
var bresult=btrue| | Bunknow;
Console.log (Bresult); Outpus true
var Bfalse=false;
var bresult=bfalse| | Bunknow;
Console.log (Bresult);
and a finite number, the usual sign rules apply:When two non-infinite numbers are multiplied by "0", the usual multiplication rules can be used.
> Signed (+0 *-5)
'-0 '
> Signed (-0 *-5)
' +0 '
Multiplying an infinity with a zero results in NaN:The infinity number is multiplied by "0" and the result is not a number (NaN)
>-infinity
Unary operatorThe unary operator, when processing all non-numeric values, translates the value through number () to a numeric value.Bitwise operators
Negative numbers are stored in the form of twos complement on the computer, and the complement is equal to the original code's inverse code plus 1,ecmascript when you output a negative number as a binary string, we see just the binary code with the negative absolute value preceded by a symbol (instead of the output 32-bit bina
); // ' false ' true); // ' true 'Therefore, using the plus operator's attributes, you can convert the value of any type to a string using the ' + 'In the numerical addition operation, the processing of Infinity and signed 0 is more special.Number.MAX_VALUE + Number.MAX_VALUE = = = Infinity; // true Infinity + (-infinity
JavaScript learning notes operator (continued), javascript learning notes
I. Multiplication Operators
1. Multiplication :*
Special rules for multiplication operators:
If the operands are all numeric values, they are calculated by regular multiplication. If the product exceeds the range indicated by the ECMAscript value, infinity or-infinity is returned.If one of the operands is NaN, the returned result is N
0, return false
* If the OP count is null, return True
* If the OP count is NaN, return True
* If the OP count is undefined, there's a mistake.
!! sblue, the first not operator returns a Boolean value. The second not will be negative for this boolean value
The logical AND operation does not necessarily return a Boolean value:
* If one of the operands is an object and the other is a Boolean value, return the object.
* If two operands are objects, the second object is returned.
* If a shipment c
, as long as can fill 8 bits of the binary, you can.If you want to maximize the initial, the first bit is the sign bit, cannot be 1, the rest is all 1, that is, 7 1,1111111 to hexadecimal just for 0x7f, so memset (, 0x7f,sizeof ());the technique of setting infinite constants in MemsetIf the scope of the data in the problem is clear, then infinity is not a problem, in the case of unclear, many programmers take0x7fffffffAs infinitely large as this ismax
problems, NaN makes it possible to simply continue the loop to perform operations that have no errors, even if a loop has made such an error. You might think that, now that Java has an exception handling mechanism, you might be able to achieve the same effect by capturing and ignoring exceptions. However, you know that the IEEE standard is not designed for Java alone, and that different languages handle exceptions differently, which makes it more difficult to migrate code. Moreover, not all lan
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.