ME Round to Odd/Even
Round numbers to the nearest odd or even integer.
Numbers to round to the nearest integer with the requested parity.
Requested integer parity. 0 = Even, 1 = Odd. If the list is shorter than Number, its last value is repeated.
Numbers rounded to the nearest integer with the requested odd or even parity.
Description
Rounds one or more numbers to the nearest integer with a specified odd or even parity. Mode 0 selects an even result and Mode 1 selects an odd result.
Inputs
Number
NNumbers to round to the nearest integer with the requested parity.
Mode
MoptionalRequested integer parity. 0 = Even, 1 = Odd. If the list is shorter than Number, its last value is repeated.
Outputs
Rounded
RNumbers rounded to the nearest integer with the requested odd or even parity.
Examples
Round to even
Round numbers to the nearest even integer.
[1.2, 2.7, 3.4] with M = 0[2, 2, 4]Round to odd
Round numbers to the nearest odd integer.
[1.2, 2.7, 3.4] with M = 1[1, 3, 3]Mode list with Repeat Last
When the Mode list is shorter than Number, the last Mode value is repeated. Extra Mode values are ignored.
Number = [1.2, 2.7, 3.4, 4.9], Mode = [0, 1][2, 3, 4, 5]Notes
- Mode 0 means Even.
- Mode 1 means Odd.
- Number is the master list and determines the number of output items.
- If Mode contains fewer items than Number, the last Mode value is repeated.
- If Mode contains more items than Number, extra Mode values are ignored.
- The output always contains the same number of items as the Number input.
- For values exactly halfway between two valid integers, the nearest valid integer is selected according to the requested parity.
- The Number input accepts a list of numbers.
Errors
- !Mode must be 0 (Even) or 1 (Odd).
- !Number cannot contain NaN or Infinity.