LGF_GetFactorial (FC / V3.0.1)

Overview

Author: Siemens Digital Industry

Short description

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

Block Interface

LGF_GetFactorial (FC)
Int  naturalNumber Ret_Val  DInt
    
   error  Bool
    
   status  Word
    
   

Input parameter

IdentifierData type Description
naturalNumberInt Natural number (0..12)

Output parameter

IdentifierData type Description
Ret_ValDInt Calculated factorial
errorBool FALSE: No error
TRUE: An error occurred during the execution of the FB
statusWord 16#0000-16#7FFF: Status of the FB
16#8000-16#FFFF: Error identification (see following Table)

Status & Error codes

Code / ValueIdentifier / Description
16#0000STATUS_NO_ERROR
Execution finished without errors
16#8101ERR_WRONG_VALUE_RANGE
Error: Input value out of range Permissible value range is 0..12

Change log

Version & DateChange description
01.00.00Siemens Industry Online Support
03.07.2018First released version
01.00.01Siemens Industry Online Support
17.08.2018Upgrade: TIA V15 Update 2
01.00.02Siemens Industry Online Support
23.11.2018Upgrade: TIA V15.1
01.01.00Siemens Industry Online Support
23.09.2019Renamed 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.00Siemens Industry Support
23.04.2020Set version to V3.0.0, harmonize the version of the whole library
03.00.01Simatic Systems Support
12.11.2020Insert documentation