Instant properties: trunc

The instant property trunc represents the given float operand rounded by removing the fractional part.

Declaration

float float.trunc

Discussion

The instant property trunc returns the integer part of the operand in context of which the property is evaluated by removing the fractional digits. Please note, the instant property trunc is read-only. The write access to this property is not allowed. For example:

var float f1 = 11.3; var float f2 = -5.3; var float f3 = -7.7; var float result1 = f1.trunc; // result1 = 11.0 var float result2 = f2.trunc; // result2 = -5.0 var float result3 = f3.trunc; // result3 = -7.0 // Write access is not allowed f1.trunc = 10.0; // Chora Compiler error

See also the built-in function math_trunc() as well as the cognate instant properties floor, round, ceil and fract.