Number is implemented using a double-precision floating point Number, the following situation is reasonable:
0.1 + 0.2 // 0.30000000000000004
3. Math
The following method is similar to the static method of the Math class in Java.
Math.pi // 3.141592653589793
Math. cos (Math. PI) //-1
3.1 convert the string into numbers: parseInt and parseFloat methods:
ParseInt ("123") = 123 (decimal conversion)
ParseInt ("010") = 8 (octal conversion)
ParseInt ("0 xCAFE") = 51966 (hexadecimal conversion)
Parse
The article does not elaborate on the specific contents of the various points of knowledge, only the main points listed, for everyone to learn the time reference, or to detect whether they are proficient in JavaScript, clear the contents of the various parts.The built-in object can be divided into Data encapsulation class object, tool class object, error class object, as follows. Data Encapsulation Class object:
Number Object
String Object
Boolean Object
Array Object
O
(overflow)
The result of the operation exceeds the maximum number that JavaScript can represent.
More than the positive maximum is expressed as Infinity
The maximum of the negative is expressed as-infinity.
Underflow (underflow)
The result of the operation is infinitely close to 0 and is smaller than the minimum value that JavaScript can represent.
Posit
a semicolon ";", the following is the full format:var t = "Hello,world";Note that JavaScript is case-sensitive;Third, JavaScriptNotesJavaScript can be divided into single-line comments and multiline comments// represents a single-line comment /* represents a multiline comment */Iv. JavaScript variablesJavaScript can be divided into global variables and local variables, declaring variables if the keyword var is represented as a local variable, it should be noted that the variable name cannot be
This section describes how to master the numbers and date types in JavaScriptDigitalEDITIn JavaScript, numbers are double-precision floating-point types double-precision 64-bit binary format IEEE 754 (that is, A number can only be between-(253-1) and 253-1). there is no specific data type for integer type. In addition to being able to represent floating-point numbers, the number type has three symbol values: + Infinity , -
I. Method of type conversion and precautions:1.Convert to boolean:(1) Using two non-operations(!) :!! 5 ==> true(2) Use a Boolean constructor:New Boolean (5) ==> trueConvert value to boolean typeFalse:0,+ 0,-0,NaN,""(Null String), Undefined, nullOther values except the preceding values are convertedTrueWhich of the following is important?:"0", new Object (), function (){}2.Convert to string type:(1) Add a Null String"":123 + "" = "123"(2) String constructor:New String (123) = "123 ".Conversions
selection of effective algorithms. For each function f (n) and time t in the following table, find the maximum number of n problems that can be solved within the time t. Assume that the algorithm used to solve the problem requires f (n) milliseconds to solve the problem.
1 second
1 minute
1 hour
1 day
1 month
1 year
1 Century
LgN
2 ^ 1000
Positive infinity
Positive
1. Character Set
Unicode characters. Each character in Javascript (Js) programs is expressed in two bytes. A 16-bit Unicode code can represent every written language commonly used on the earth.
2. Data Type
Number)
All numbers are represented in floating point format, in a 64-bit floating point format defined in the IEEE 754 standard. Note that some integer operations (such as bit operations) are performed on 32-bit integers.
Some special numerical constants:
NaN (Number. NaN), special non-numer
JS data types are divided into primitive types (num, String, Boolean), Object types (objects, collections of attributes, special objects are arrays, global objects ), primitive values (null,undefined), except for primitive values, others have methodsJS is flexible for data type conversionAttention:1, Number type: overflow in arithmetic operation, underflow, or divide by zero will not error,If the overflow result is infinite, it returns infinity, and n
JavaScript data types are divided into primitive types (primitive type) and reference types (complex type).First, the original typeJavaScript has 5 primitive types (primitive type), that is, Undefined, Null, Boolean, number, and String.1.Number typeThis type can represent both a 32-bit integer and a 64-bit floating-point number.A special number value:The first two are Number.MAX_VALUE and Number.min_value, which define the outer bounds of the set of number values. All ECMAScript numbers must be
memory.Of the 8 basic data types, only char and Boolean are unsigned numbers. and the value range of the Boolean type is 0 or the range of 1,char type is [0,65535]. We generally think that the value of the char type is non-negative.The floating-point type of Java is in IEEE 754 floating-point number format. In the case of float, floating-point types typically have two 0,+0.0f and -0.0f. The former is 0 in Java, the latter is a floating-point number with a sign bit of 1 and the other bits are 0,
The following are the most basic data type comparisons.650) this.width=650; "src=" Http://www.grabsun.com/uploads/images/201206-2/144721_08_738.GIF "alt=" 144721_08_738. GIF "/>Explain the points:1. It can also be divided into two main categories: Boolean and numeric (mainly for data conversion)(Note that Boolean cannot be converted with other types, and it is not possible to assign a Boolean to a type such as int)A 2.String string is not a basic data type, a string is a class, that is, a refere
) type in the IEEE standard. This means that number causes the following precision rounding error:
1
0.1 + 0.2 = = 0.3//false
Because integers and floats are no different, unlike C # and Java, the following code is true:
1
0.0 = = 0; True
Finally, a question about number, how do we implement the following question:
1 2
A = = = B; True 1/a = = 1/b; False
The answer is that the specification of number is allowed to ap
63px 63px 63px/108px 108px 72px 72px;border-radius:50% 50% 50% 50%/60% 60% 40% 40%;}
Infinity symbol:The infinity symbol can be achieved by border the property and setting the angle of the pseudo-element.#infinity {width:220px;height:100px;position:relative;}#infinity: Before, #
= 666;int64 Longvalue = 2147483648; Single Floatvalue = 3.14f;double Doublevalue = 999.99;decimal Decimalvalue = 86400.35627m;In JavaScript there is only one numeric type, the number type, which includes integers and floating-point numbers.There are 3 special representations of the number types of javascript:
Inifiity: Infinity of Positive
-inifity: Negative Infinity
NaN: Non-numeric (not
;Float f2 = 0;Float f3 = f1/f2;If you see the above Code, will you immediately think of DividedByZeroException. If these numbers are integers, an exception is thrown, but these numbers are floating-point numbers, and no exception is thrown here,In fact, floating-point calculation never produces exceptions, because f2 is not really 0, it is just a number very close to 0 (For details, refer to my previous article ). In this case, f3 is equal to a special value. It is
than or equal to 2 of the 53 can be accurately represented. An operation with a value greater than 2 after 53 will begin to appear in error. The number of valid digits (the last three bits of 111) will not be saved and become 0.Special values:One, positive 0 and minus 01. In strict terms, JavaScript provides 0 of the three kinds of notation: 0, +0,-0. They are equivalent.2. If positive 0 and negative 0 are used as the denominator of the divisor, the result is different.+0--〉+
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.