diff --git a/base/src/test/test_even_odd b/base/src/test/test_even_odd new file mode 100644 index 0000000..d406aeb --- /dev/null +++ b/base/src/test/test_even_odd @@ -0,0 +1,23 @@ +#![allow(clippy::unwrap_used)] + +use crate::test::util::new_empty_model; + +#[test] +fn arguments() { + let mut model = new_empty_model(); + model._set("A1", "=EVEN(2)"); + model._set("A2", "=ODD(2)"); + model._set("A3", "=EVEN()"); + model._set("A4", "=ODD()"); + model._set("A5", "=EVEN(1, 2)"); + model._set("A6", "=ODD(1, 2)"); + + model.evaluate(); + + assert_eq!(model._get_text("A1"), *"2"); + assert_eq!(model._get_text("A2"), *"3"); + assert_eq!(model._get_text("A3"), *"#ERROR!"); + assert_eq!(model._get_text("A4"), *"#ERROR!"); + assert_eq!(model._get_text("A5"), *"#ERROR!"); + assert_eq!(model._get_text("A6"), *"#ERROR!"); +} diff --git a/docs/src/functions/math-and-trigonometry.md b/docs/src/functions/math-and-trigonometry.md index f2d8f3b..7209afb 100644 --- a/docs/src/functions/math-and-trigonometry.md +++ b/docs/src/functions/math-and-trigonometry.md @@ -37,7 +37,7 @@ You can track the progress in this [GitHub issue](https://github.com/ironcalc/Ir | CSCH | | – | | DECIMAL | | – | | DEGREES | | [DEGREES](math_and_trigonometry/degrees) | -| EVEN | | – | +| EVEN | | [EVEN](math_and_trigonometry/even) | | EXP | | – | | FACT | | – | | FACTDOUBLE | | – | @@ -49,9 +49,9 @@ You can track the progress in this [GitHub issue](https://github.com/ironcalc/Ir | ISO.CEILING | | – | | LCM | | – | | LET | | – | -| LN | | – | -| LOG | | – | -| LOG10 | | – | +| LN | | – | +| LOG | | – | +| LOG10 | | – | | MDETERM | | – | | MINVERSE | | – | | MMULT | | – | @@ -59,7 +59,7 @@ You can track the progress in this [GitHub issue](https://github.com/ironcalc/Ir | MROUND | | – | | MULTINOMIAL | | – | | MUNIT | | – | -| ODD | | – | +| ODD | | [ODD](math_and_trigonometry/odd) | | PI | | – | | POWER | | – | | PRODUCT | | – | @@ -80,7 +80,7 @@ You can track the progress in this [GitHub issue](https://github.com/ironcalc/Ir | SIN | | [SIN](math_and_trigonometry/sin) | | SINH | | [SINH](math_and_trigonometry/sinh) | | SQRT | | – | -| SQRTPI | | – | +| SQRTPI | | – | | SUBTOTAL | | – | | SUM | | – | | SUMIF | | – | diff --git a/docs/src/functions/math_and_trigonometry/even.md b/docs/src/functions/math_and_trigonometry/even.md index 2998918..ea97082 100644 --- a/docs/src/functions/math_and_trigonometry/even.md +++ b/docs/src/functions/math_and_trigonometry/even.md @@ -4,9 +4,41 @@ outline: deep lang: en-US --- -# EVEN +# EVEN function -::: warning -🚧 This function is not yet available in IronCalc. -[Follow development here](https://github.com/ironcalc/IronCalc/labels/Functions) -::: \ No newline at end of file +## Overview +EVEN is a function of the Math and Trigonometry category that rounds a number up (away from zero) to the nearest even integer. + +## Usage +### Syntax +**EVEN(number) => even** + +### Argument descriptions +* *number* ([number](/features/value-types#numbers), required). The number that is to be rounded to the nearest even integer. + +### Additional guidance +* EVEN rounds away from zero, meaning: + * Positive numbers are rounded up to the next even integer. + * Negative numbers are rounded down (toward negative infinity) to the next even integer. +* If the *number* argument is already an even integer, EVEN returns it unchanged. +* Since zero is considered an even number, the EVEN function returns 0 when *number* is 0. + +### Returned value +EVEN returns a [number](/features/value-types#numbers) that is the nearest even integer, rounded away from zero. + +### Error conditions +* In common with many other IronCalc functions, EVEN propagates errors that are found in its argument. +* If no argument, or more than one argument, is supplied, then EVEN returns the [`#ERROR!`](/features/error-types.md#error) error. +* If the value of the *number* argument is not (or cannot be converted to) a [number](/features/value-types#numbers), then EVEN returns the [`#VALUE!`](/features/error-types.md#value) error. + + + + +## Links +* For more information about even and odd numbers, visit Wikipedia's [Parity](https://en.wikipedia.org/wiki/Parity_(mathematics)) page. +* See also IronCalc's [ODD](/functions/math_and_trigonometry/odd) function. +* Visit Microsoft Excel's [EVEN function](https://support.microsoft.com/en-us/office/even-function-197b5f06-c795-4c1e-8696-3c3b8a646cf9) page. +* Both [Google Sheets](https://support.google.com/docs/answer/3093409) and [LibreOffice Calc](https://wiki.documentfoundation.org/Documentation/Calc_Functions/EVEN) provide versions of the EVEN function. \ No newline at end of file diff --git a/docs/src/functions/math_and_trigonometry/odd.md b/docs/src/functions/math_and_trigonometry/odd.md index 7348500..5f4b5f1 100644 --- a/docs/src/functions/math_and_trigonometry/odd.md +++ b/docs/src/functions/math_and_trigonometry/odd.md @@ -4,9 +4,41 @@ outline: deep lang: en-US --- -# ODD +# ODD function -::: warning -🚧 This function is not yet available in IronCalc. -[Follow development here](https://github.com/ironcalc/IronCalc/labels/Functions) -::: \ No newline at end of file +## Overview +ODD is a function of the Math and Trigonometry category that rounds a number up (away from zero) to the nearest odd integer. + +## Usage +### Syntax +**ODD(number) => odd** + +### Argument descriptions +* *number* ([number](/features/value-types#numbers), required). The number that is to be rounded to the nearest odd integer. + +### Additional guidance +* ODD rounds away from zero, meaning: + * Positive numbers are rounded up to the next odd integer. + * Negative numbers are rounded down (toward negative infinity) to the next odd integer. +* If the *number* argument is already an odd integer, ODD returns it unchanged. +* Since zero is considered an even number, the ODD function returns 1 when *number* is 0. + +### Returned value +ODD returns a [number](/features/value-types#numbers) that is the nearest odd integer, rounded away from zero. + +### Error conditions +* In common with many other IronCalc functions, ODD propagates errors that are found in its argument. +* If no argument, or more than one argument, is supplied, then ODD returns the [`#ERROR!`](/features/error-types.md#error) error. +* If the value of the *number* argument is not (or cannot be converted to) a [number](/features/value-types#numbers), then ODD returns the [`#VALUE!`](/features/error-types.md#value) error. + + + + +## Links +* For more information about even and odd numbers, visit Wikipedia's [Parity](https://en.wikipedia.org/wiki/Parity_(mathematics)) page. +* See also IronCalc's [EVEN](/functions/math_and_trigonometry/even) function. +* Visit Microsoft Excel's [ODD function](https://support.microsoft.com/en-us/office/odd-function-deae64eb-e08a-4c88-8b40-6d0b42575c98) page. +* Both [Google Sheets](https://support.google.com/docs/answer/3093499) and [LibreOffice Calc](https://wiki.documentfoundation.org/Documentation/Calc_Functions/ODD) provide versions of the ODD function. \ No newline at end of file diff --git a/xlsx/tests/calc_tests/EVEN_ODD.xlsx b/xlsx/tests/calc_tests/EVEN_ODD.xlsx new file mode 100644 index 0000000..4ffe6e3 Binary files /dev/null and b/xlsx/tests/calc_tests/EVEN_ODD.xlsx differ