Truncate or floor a number with decimal digits to a whole number.
XSharp.RT (in XSharp.RT.dll) Version: 2.5
nValue AS USUAL
) AS USUAL
public static Usual Integer(
- Type: Usual
The number to truncate or floor.
The whole number to the left of the decimal point. Since both <uValue> and the return value are data type USUAL, you are not limited to the size of an integer.
Integer() converts a numeric value to an integer by taking the floor of the number. Note – this is not the same as truncation except for positive integers — it is not rounding. Integer() is useful in operations where the decimal portion of a number is not needed.
Note that a loss of precision on floating numbers might be significant.
For example, you might not know that a number is internally represented as 0.99999999999999999, because, when that number is displayed with QOut() or passed to the Str() function, internal rounding returns a value of 1.0.
When a number like that is passed to the Integer() function, however, its decimal portion is truncated and a value of zero is returned.
If this is not what you had intended, you can use Round(<nValue>, 0) instead of Integer().
Integer() is the same as the Int() function in CA-Clipper, but INT is a reserved word in X#.
Under X#, Int() is a conversion operator. With numbers that are not greater than a short integer, it yields the same results as Integer() and maintains compatibility with CA-Clipper.
These examples demonstrate the results of various invocations of the Integer() function: