update: adds docs, unit tests and xlsx tests for EVEN and ODD functions (#517)
* update: adds unit test for EVEN and ODD functions * update: adds xlsx test for EVEN and ODD functions * update: adds EVEN and ODD doc pages * update: Math and Trigonometry main page links to new functions * update: changes to functions badge type in main Math and Trigonometry page
This commit is contained in:
23
base/src/test/test_even_odd
Normal file
23
base/src/test/test_even_odd
Normal file
@@ -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!");
|
||||||
|
}
|
||||||
@@ -37,7 +37,7 @@ You can track the progress in this [GitHub issue](https://github.com/ironcalc/Ir
|
|||||||
| CSCH | <Badge type="info" text="Not implemented yet" /> | – |
|
| CSCH | <Badge type="info" text="Not implemented yet" /> | – |
|
||||||
| DECIMAL | <Badge type="info" text="Not implemented yet" /> | – |
|
| DECIMAL | <Badge type="info" text="Not implemented yet" /> | – |
|
||||||
| DEGREES | <Badge type="info" text="Not implemented yet" /> | [DEGREES](math_and_trigonometry/degrees) |
|
| DEGREES | <Badge type="info" text="Not implemented yet" /> | [DEGREES](math_and_trigonometry/degrees) |
|
||||||
| EVEN | <Badge type="info" text="Not implemented yet" /> | – |
|
| EVEN | <Badge type="info" text="Not implemented yet" /> | [EVEN](math_and_trigonometry/even) |
|
||||||
| EXP | <Badge type="info" text="Not implemented yet" /> | – |
|
| EXP | <Badge type="info" text="Not implemented yet" /> | – |
|
||||||
| FACT | <Badge type="info" text="Not implemented yet" /> | – |
|
| FACT | <Badge type="info" text="Not implemented yet" /> | – |
|
||||||
| FACTDOUBLE | <Badge type="info" text="Not implemented yet" /> | – |
|
| FACTDOUBLE | <Badge type="info" text="Not implemented yet" /> | – |
|
||||||
@@ -49,9 +49,9 @@ You can track the progress in this [GitHub issue](https://github.com/ironcalc/Ir
|
|||||||
| ISO.CEILING | <Badge type="info" text="Not implemented yet" /> | – |
|
| ISO.CEILING | <Badge type="info" text="Not implemented yet" /> | – |
|
||||||
| LCM | <Badge type="info" text="Not implemented yet" /> | – |
|
| LCM | <Badge type="info" text="Not implemented yet" /> | – |
|
||||||
| LET | <Badge type="info" text="Not implemented yet" /> | – |
|
| LET | <Badge type="info" text="Not implemented yet" /> | – |
|
||||||
| LN | <Badge type="info" text="Available" /> | – |
|
| LN | <Badge type="tip" text="Available" /> | – |
|
||||||
| LOG | <Badge type="info" text="Available" /> | – |
|
| LOG | <Badge type="tip" text="Available" /> | – |
|
||||||
| LOG10 | <Badge type="info" text="Available" /> | – |
|
| LOG10 | <Badge type="tip" text="Available" /> | – |
|
||||||
| MDETERM | <Badge type="info" text="Not implemented yet" /> | – |
|
| MDETERM | <Badge type="info" text="Not implemented yet" /> | – |
|
||||||
| MINVERSE | <Badge type="info" text="Not implemented yet" /> | – |
|
| MINVERSE | <Badge type="info" text="Not implemented yet" /> | – |
|
||||||
| MMULT | <Badge type="info" text="Not implemented yet" /> | – |
|
| MMULT | <Badge type="info" text="Not implemented yet" /> | – |
|
||||||
@@ -59,7 +59,7 @@ You can track the progress in this [GitHub issue](https://github.com/ironcalc/Ir
|
|||||||
| MROUND | <Badge type="info" text="Not implemented yet" /> | – |
|
| MROUND | <Badge type="info" text="Not implemented yet" /> | – |
|
||||||
| MULTINOMIAL | <Badge type="info" text="Not implemented yet" /> | – |
|
| MULTINOMIAL | <Badge type="info" text="Not implemented yet" /> | – |
|
||||||
| MUNIT | <Badge type="info" text="Not implemented yet" /> | – |
|
| MUNIT | <Badge type="info" text="Not implemented yet" /> | – |
|
||||||
| ODD | <Badge type="info" text="Not implemented yet" /> | – |
|
| ODD | <Badge type="info" text="Not implemented yet" /> | [ODD](math_and_trigonometry/odd) |
|
||||||
| PI | <Badge type="info" text="Not implemented yet" /> | – |
|
| PI | <Badge type="info" text="Not implemented yet" /> | – |
|
||||||
| POWER | <Badge type="tip" text="Available" /> | – |
|
| POWER | <Badge type="tip" text="Available" /> | – |
|
||||||
| PRODUCT | <Badge type="tip" text="Available" /> | – |
|
| PRODUCT | <Badge type="tip" text="Available" /> | – |
|
||||||
@@ -80,7 +80,7 @@ You can track the progress in this [GitHub issue](https://github.com/ironcalc/Ir
|
|||||||
| SIN | <Badge type="tip" text="Available" /> | [SIN](math_and_trigonometry/sin) |
|
| SIN | <Badge type="tip" text="Available" /> | [SIN](math_and_trigonometry/sin) |
|
||||||
| SINH | <Badge type="tip" text="Available" /> | [SINH](math_and_trigonometry/sinh) |
|
| SINH | <Badge type="tip" text="Available" /> | [SINH](math_and_trigonometry/sinh) |
|
||||||
| SQRT | <Badge type="tip" text="Available" /> | – |
|
| SQRT | <Badge type="tip" text="Available" /> | – |
|
||||||
| SQRTPI | <Badge type="info" text="Available" /> | – |
|
| SQRTPI | <Badge type="tip" text="Available" /> | – |
|
||||||
| SUBTOTAL | <Badge type="info" text="Not implemented yet" /> | – |
|
| SUBTOTAL | <Badge type="info" text="Not implemented yet" /> | – |
|
||||||
| SUM | <Badge type="tip" text="Available" /> | – |
|
| SUM | <Badge type="tip" text="Available" /> | – |
|
||||||
| SUMIF | <Badge type="tip" text="Available" /> | – |
|
| SUMIF | <Badge type="tip" text="Available" /> | – |
|
||||||
|
|||||||
@@ -4,9 +4,41 @@ outline: deep
|
|||||||
lang: en-US
|
lang: en-US
|
||||||
---
|
---
|
||||||
|
|
||||||
# EVEN
|
# EVEN function
|
||||||
|
|
||||||
::: warning
|
## Overview
|
||||||
🚧 This function is not yet available in IronCalc.
|
EVEN is a function of the Math and Trigonometry category that rounds a number up (away from zero) to the nearest even integer.
|
||||||
[Follow development here](https://github.com/ironcalc/IronCalc/labels/Functions)
|
|
||||||
:::
|
## Usage
|
||||||
|
### Syntax
|
||||||
|
**EVEN(<span title="Number" style="color:#1E88E5">number</span>) => <span title="Number" style="color:#1E88E5">even</span>**
|
||||||
|
|
||||||
|
### 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.
|
||||||
|
<!--@include: ../markdown-snippets/error-type-details.txt-->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
## Examples
|
||||||
|
[See some examples in IronCalc](https://app.ironcalc.com/?example=even).
|
||||||
|
-->
|
||||||
|
|
||||||
|
## 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.
|
||||||
@@ -4,9 +4,41 @@ outline: deep
|
|||||||
lang: en-US
|
lang: en-US
|
||||||
---
|
---
|
||||||
|
|
||||||
# ODD
|
# ODD function
|
||||||
|
|
||||||
::: warning
|
## Overview
|
||||||
🚧 This function is not yet available in IronCalc.
|
ODD is a function of the Math and Trigonometry category that rounds a number up (away from zero) to the nearest odd integer.
|
||||||
[Follow development here](https://github.com/ironcalc/IronCalc/labels/Functions)
|
|
||||||
:::
|
## Usage
|
||||||
|
### Syntax
|
||||||
|
**ODD(<span title="Number" style="color:#1E88E5">number</span>) => <span title="Number" style="color:#1E88E5">odd</span>**
|
||||||
|
|
||||||
|
### 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.
|
||||||
|
<!--@include: ../markdown-snippets/error-type-details.txt-->
|
||||||
|
|
||||||
|
<!--
|
||||||
|
## Examples
|
||||||
|
[See some examples in IronCalc](https://app.ironcalc.com/?example=odd).
|
||||||
|
-->
|
||||||
|
|
||||||
|
## 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.
|
||||||
BIN
xlsx/tests/calc_tests/EVEN_ODD.xlsx
Normal file
BIN
xlsx/tests/calc_tests/EVEN_ODD.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user