Round()

Syntax

Result.f(.d) = Round(Number.f(.d), Mode)
Description
Round the specified float number according to the given mode.

Parameters

Number.f or Number.d The number to round.
Mode The rounding mode. This can be one of the following values:
  #PB_Round_Down   : rounds down the number
  #PB_Round_Up     : rounds up the number
  #PB_Round_Nearest: rounds to the nearest integer number (0.5 and up will round up)

Remarks

To turn a floating-point number into an integer without rounding, use Int() or IntQ(). This function handles and returns float or double values.

Example

  Debug Round(11.6, #PB_Round_Down)    ; Will print '11.0'
  Debug Round(-3.6, #PB_Round_Down)    ; Will print '-4.0'

  Debug Round(11.6, #PB_Round_Up)      ; Will print '12.0'
  Debug Round(-1.6, #PB_Round_Up)      ; Will print '-1.0'

  Debug Round(11.6, #PB_Round_Nearest) ; Will print '12.0'
  Debug Round(11.4, #PB_Round_Nearest) ; Will print '11.0'
  Debug Round(11.5, #PB_Round_Nearest) ; Will print '12.0'
  Debug Round(-7.5, #PB_Round_Nearest) ; Will print '-8.0'

See Also

Int(), IntQ()

Supported OS

All

<- RandomSeed() - Math Index - Sign() ->