Round()

Syntax

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

Parameters

Number.f 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 can handle float and double values.

Example

  Debug Round(11.6, #PB_Round_Down)    ; Will print '11'
  Debug Round(-3.6, #PB_Round_Down)    ; Will print '-4'

  Debug Round(11.6, #PB_Round_Up)      ; Will print '12'
  Debug Round(-1.6, #PB_Round_Up)      ; Will print '-1'

  Debug Round(11.6, #PB_Round_Nearest) ; Will print '12'
  Debug Round(11.4, #PB_Round_Nearest) ; Will print '11'
  Debug Round(11.5, #PB_Round_Nearest) ; Will print '12'
  Debug Round(-7.5, #PB_Round_Nearest) ; Will print '-8'

See Also

Int(), IntQ()

Supported OS

All

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