QB64.com

QB64 is a modern extended BASIC programming language that retains QBasic/QuickBASIC 4.5 compatibility and compiles native binaries for Windows, Linux, and macOS.

The FIX function rounds a numerical value to the next whole number closest to zero.

Syntax

result = FIX(expression)

Parameter(s)

Description

Example(s)

Showing the behavior of FIX with positive and negative decimal point values.


 PRINT FIX(2.5)
 PRINT FIX(-2.5) 

2 
-2

The NORMAL arithmetic method (round half up) can be achieved using the function in the example code below:


PRINT MATHROUND(0.5) 
PRINT MATHROUND(1.5)
PRINT MATHROUND(2.5)
PRINT MATHROUND(3.5)
PRINT MATHROUND(4.5)
PRINT MATHROUND(5.5)

FUNCTION MATHROUND(n)
    MATHROUND = FIX(n + 0.5 * SGN(n))
END FUNCTION 

1
2
3
4
5
6

See Also