The function calculates the faculty of a natural number (\mathbb{N}!) and returns the result.
The permissible value range of the input parameter naturalNumber
is between 0 and 12, as 12 is the maximum factorial result fitting into a DInt type
LGF_GetFactorial (FC) | ||||||||
---|---|---|---|---|---|---|---|---|
Int | naturalNumber | Ret_Val | DInt | |||||
error | Bool | |||||||
status | Word | |||||||
Identifier | Data type | Description |
---|---|---|
naturalNumber | Int | Natural number (0..12) |
Identifier | Data type | Description |
---|---|---|
Ret_Val | DInt | Calculated factorial |
error | Bool | FALSE: No error TRUE: An error occurred during the execution of the FB |
status | Word | 16#0000-16#7FFF: Status of the FB 16#8000-16#FFFF: Error identification (see following Table) |
Code / Value | Identifier / Description |
---|---|
16#0000 | STATUS_NO_ERROR Execution finished without errors |
16#8101 | ERR_WRONG_VALUE_RANGE Error: Input value out of range Permissible value range is 0..12 |
Version & Date | Change description | |
---|---|---|
01.00.00 | Siemens Industry Online Support | |
03.07.2018 | First released version | |
01.00.01 | Siemens Industry Online Support | |
17.08.2018 | Upgrade: TIA V15 Update 2 | |
01.00.02 | Siemens Industry Online Support | |
23.11.2018 | Upgrade: TIA V15.1 | |
01.01.00 | Siemens Industry Online Support | |
23.09.2019 | Renamed from "Factorial" to "GetFactorial" Code refactoring, regions and more comments added Reworked to case of, MAGIC numbers are okay as they stay for the number/case itself | |
03.00.00 | Siemens Industry Support | |
23.04.2020 | Set version to V3.0.0, harmonize the version of the whole library | |
03.00.01 | Simatic Systems Support | |
12.11.2020 | Insert documentation |