Skip to content

FIX ​


Returns the integer part of a number, rounding towards zero

Syntax ​

vb
declare function Fix ( byval number as single ) as single
declare function Fix ( byval number as double ) as double
declare function Fix ( byval number as integer ) as integer
declare function Fix ( byval number as uinteger ) as uinteger

Usage ​

` result = Fix( number )

`

Parameters ​

number

the floating-point number to truncate

Return Value ​

Returns the integer part of number, rounding towards zero.

Description ​

Equivalent to: Sgn(number) * Int(Abs(number)). For example, Fix(1.3) will return 1.0, and Fix(-4.9) will return -4.0. For integer types, the number is returned unchanged.

Note: this function is also equivalent to number - Frac(number).

The Fix unary operator can be overloaded with user defined types.

Examples ​

start GeSHi

vb
Print Fix(1.9)  '' will print  1
Print Fix(-1.9) '' will print -1

end GeSHi

Dialect Differences ​

  • In the -lang qb dialect, this operator cannot be overloaded.

Differences from QB ​

  • None

See also ​

  • Int
  • Frac
  • Cint
  • Operator

Back to DocToc

Translated from FreeBASIC official docs. Contact us for removal if infringed.
FreeBASIC is an open-source project, not affiliated with Microsoft