Integer and Fetch _ Application tips in ASP (VBScript)

Source: Internet
Author: User
Tags integer division

Divisible

Integer division in ASP (VBScript) is "\", such as M = 5 \ 2, and the result is 2.

Take more

Use mod in ASP (VBScript), such as M = 5 mod 2, and the result is 1.

Large number of attention

m = 4444444444/2
n = 4444444444 \ 2

The first sentence is correct, and the second sentence runs with an overflow error because: The numeric expression is rounded to a Byte, an Integer, or a Long subtype before the divide-and-take operation. The Long subtype has a range of [-2147483648, 2147483647], that is, the number that is to be divisible or fetched must be within that range.

Several rounding functions in ASP

Several rounding functions in ASP are: Fix (), int (), round ();

The Int (number) function returns the integer portion of a digit. The number argument can be any valid numeric expression. Returns NULL if the number parameter contains null.
Cases:

Copy Code code as follows:

Response.Write Int (2.14) ' 2
Response.Write Fix (2.14) ' 2
Response.Write Int (2.54) ' 2
Response.Write Int (2.54) ' 2

Both the Int and the Fix functions delete the decimal part of the number parameter and return the result expressed as an integer. The difference between an int and the Fix function is that if the number argument is a negative number, the INT function returns the first negative integer less than or equal to number, and the Fix function returns the first negative integer greater than or equal to the number parameter. For example, Int converts 8.4 to 9, and the Fix function converts-8.4 to 8.

Round (expression[, numdecimalplaces]) returns a value that is rounded by a specified number of digits. Expression is a required option. numeric expressions are rounded. Numdecimalplaces is optional. The number indicates how many digits to the right of the decimal point are rounded. If omitted, the Round function returns an integer.
Cases:

Copy Code code as follows:

Response.Write Round (3.14) ' 3
Response.Write Round (3.55) ' 4
Response.Write Round (3.1415,3) ' 3.142

Test code:

<%
Response.Write 650\100& "<br>"
Response.Write Int (650/100) & "<br>"
Response.Write Fix (650/100) & "<br>"
Response.Write Int (2.54) & "<br>"
Response.Write int (2.54) & "<br>"
%>
Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.