NAME

valtoint - convert to integer

SYNOPSIS

short round(d)
double d;

double fix(d)
double d;

DESCRIPTION

Round returns d rounded to the nearest integer.  If the value’s fractional part is exactly ½, it is rounded up in magnitude: if positive it is rounded to the next integer greater and if negative it is rounded to the next integer lesser.  This function implements the conversion of floating point values to integers. 

Fix returns d truncated, rounded toward zero.  The truncation is performed with ceil and floor (see floor(3)).  If the value is positive it is rounded to the greatest integer less than it.  If the value is negative it is rounded to the least integer greater than it.  This function implements the BASIC FIX function. 

SEE ALSO

fix(func)
floor(3) in the UNIX Programmer’s Manual

DIAGNOSTICS

Round generates error 6 (Overflow) if the value would overflow an integer, i.e. the value is greater than or equal to 32767.5 (exactly) or less than or equal to -32768.5 (exactly)

from The Basmark QuickBASIC Programmer’s Manual by Lawrence Leinweber