CByteRZ, CShortRZ, CIntRZ, CLongRZ, CLargeRZ Functions

Purpose

Each function coerces an expression to a specific integer data type rounding towards zero.

Syntax

Byte = CByteRZ(expression)

Short = CShortRZ(expression)

Integer = CIntRZ(expression)

Long = CLongRZ(expression)

Large = CLargeRZ(expression)

expression: aexp

Description

Converts a numeric or string expression to a specific integer data type rounding towards zero (RZ).

When expression is a string the value in the string is converted to a value using the regional settings. You should use the data-type conversion functions instead of Val to provide internationally aware conversions from one data type to another. For example, when you use CLongRZ, different decimal separators, different thousand separators, and various currency options are properly recognized depending on the locale setting of your computer.

In general, you can document your code using the data-type conversion functions to show that the result of some operation should be expressed as a particular data type rather than the default data type.

Note CByteRZ is the only function that returns an unsigned value (0 .. 256). A negative parameter is converted to a positive value.

Example

Print CByteRZ(1.999) //result: 1

Print CByteRZ("2,1") //result: 21 (UK or USA) or 2 (European)

Print CByteRZ(-1.6//result: 255

See Also

CByte, CShort, CInt, CLong, CLarge

{Created by Sjouke Hamstra; Last updated: 24/09/2014 by James Gaite}