The following describes the precision of float operations in javascript. Someone asked a js question:
The Code is as follows:
Var I = 0.07;Var r = I * 100;Alert (r );
Why is the result 7.0000000000000001?
After checking the information, we know
Someone asked a js question:Copy codeThe Code is as follows:Var I = 0.07;Var r = I * 100;Alert (r ); Why is the result 7.0000000000000001?After checking the information, we know that in JavsScript, variables are stored by float instead of the number
These three functions may be confusing for beginners. Now I am learning them and I will make a detailed record.
Math. Round () literally knows what it means. How can we get a number around a double or float number? The answer is rounding.
For
The difference between the JavascriptMathceil (), floor (), and round () functions is rounded down... Ceiling is rounded up .. Float is the rounded down integer-ceil (): the fractional part is carried to the integer part. For example, Math. ceil (12.
Someone asked a js question:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->var i = 0.07;var r = i*100;alert(r);
Why is the result 7.0000000000000001?
After checking the information, we know that
the round is rounded ... Ceiling is rounding up. Float is rounded downHere are a few ways to round decimal values to integers: Math.ceil (), Math.floor (), and Math.Round (). These three methods follow the following rounding rules, respectively:Math.
This article mainly introduces how to obtain the decimal point of any decimal point in JavaScript. If you need a friend, refer to using Javascript to get the float type two digits after the decimal point, for example, 22.127456 to 22.13. What should
Four basic data types in javascript: numeric values (integers and real numbers), string literals (characters or values enclosed by "" or "), Boolean (make True or false), and null values. The data in the basic type of JavaScript can be constants or
Summary of little knowledge about JavaScript performance optimization, and javascript Performance Optimization
With the development of the network, network speed and machine speed, more and more websites use a variety of client technologies. Ajax is
In js, the most common method for getting the decimal point and the two decimal points is the rounding function. I have previously introduced this common function in js, which is useful here, next let's take a look at some methods to sum up the two
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.