Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

What are the basic functions of the int () function

Shulou Source: shulou.com Published: 2022-06-03 01:53:40 09月29日 Update

This article will explain in detail what the basic functions of the int () function are, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.

The INT () function, one of the VFP numeric functions, rounds down a real number to be rounded (which can be a mathematical expression) to the nearest integer. Using the INT function, you can return a decimal integer, such as 4.323 and 4, which is not rounded, but tailed. Even if 4.987, it returns 4 instead of 5.

The INT function returns the integer value of the real number rounded down. Its syntax format is INT (number), where number is a real number that needs to be rounded. For example, the return value of INT (8.6) is 8, while that of INT (- 8.6) is-9. The TRUNC function truncates the decimal part of the number and returns the integer part of the number.

Its syntax format is TRUNC (number,number_digits), where number is the number to be truncated, and number_digits is the number with specified rounding precision, and the default is 0. For example, the return value of the function TRUNC (8. 5) is 8, while that of TRUNC (- 8. 5) is-8.

Although these two functions are rounding functions, their algorithms are different. The INT function returns an integer that is smaller than and closest to a given parameter, while the TRUNC function directly returns an integer that is stripped of the decimal part.

Function

The int () function converts a string of type base or number to an integer. INT (x) can find a maximum integer not greater than x.

Function

Int (xan0)

Int (x, base=10), the default value of base is 10, that is, when the value of base is not specified, the function treats x as decimal.

Grammar

The following is the syntax of the int () method:

Class int (x, base=10)

Parameters.

X-string or number.

Base-Decimal number, default to decimal.

Return value

Returns integer data.

Annotation

In some other programming languages, this function is called "rounding" function.

FIX and CINT functions also complete the rounding function.

The basic functions of the int () function are shared here. I hope the above content can be of some help to you and can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Functions integers numbers functions syntax parameters real numbers decimals parts content decimal characters strings numeric values articles more formats knowledge articles decimal Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Linux OPPO Reno macOS Shulou Information