Function Math Arithmetic Class

PreviousEven

"Previous Even Number" Returns the next smaller even number.

Signature (Visual Basic / VBA)

Public Function PreviousEven( _
    ByVal vX As Variant _
    ) As Variant

Code Example

    PreviousEven(1) = 0
    PreviousEven(2) = 0
    PreviousEven(3) = 2
    PreviousEven(22.4) = 22
    PreviousEven(-1.7) = -2
    PreviousEven(-6.5) = -8
    PreviousEven(-7.8) = -8

Parameters

Parameter Description
vX Number which is rounded-down to the previous even number (i.e. 2, 4, 6, -2, -4, -6, etc.). Function returns Null if vX is Null or cannot be fixed up to a number.

Notes & Version History

Note Similar to calling the Floor function with a precision of 2 (two), except that if vX is already an even number, this function returns the previous even number.
Note Zero is considered an even number, as are all negative numbers divisible by two.