Functions Index :: R :: RoundBs

[<< up one level]


numeric :: rounding


RoundBs(float x, int "base")


An extension to the Round standard Avisynth function for arbitrary (integer) base base.[1] It returns the base-base rounded integer of x (ie the integral multiple of base that has absolute difference from x less or equal to base/2). [2]


f1 = RoundBs(3.3, 2) # f1 == 4.0

f2 = RoundBs(7.3, 3) # f2 == 6.0

f3 = RoundBs(7.3, 1) # f3 == 7.0


[<< top]


[1]:Like the Round standard Avisynth function, RoundBs is symmetrical around the axis origin and not periodic.

Consequently, the following equalities hold:

Round(x) = k, x in (k-0.5..k+0.5) for every k in Z

RoundBs(x, b) = kb, x in ((k-0.5)*b..(k+0.5)*b) for every k in Z

[2]:The current implementation will overflow if x is near (ie less or equal than base) the maximum / minimum integer limits. This limitation may be removed in a subsequent version.