# LGF_Random_Real (FC / 3.0.1)

Overview

Author: Siemens Digital Industries

## Short description

This function generates a random value with each call.
The random number has the data type Real in the range from 0.0 to 1.0.

### Block Interface

| LGF_Random_Real (FC) |
--- | --- | ---
|  |  |  |  | Ret_Val |  |  | Real
|  |  |  |  | error |  |  | Bool
|  |  |  |  | status |  |  | Word
|  |  |  |  | subfunctionStatus |  |  | Word

### Output parameter

Identifier | Data type | Description
--- | --- | ---
Ret_Val | Real | Random Real number between 0.0 and 1.0
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)
subfunctionStatus | Word | Status or return value of called FB's, FC's and system blocks

### Status & Error codes

Code / Value | Identifier / Description
--- | ---
16#0000 | STATUS_FINISHED_NO_ERROR Execution finished without errors
16#8600 | ERR_RD_SYS_T Error in `RD_SYS_T` command - check `subFunctionStatus` code

## Functional description

Note
  The status of called commands is output in `subFunctionStatus`. In this case, the output value in `status` indicates which command caused the error. In this case, refer to the TIA Portal Online Help section for information on the respective commands.

The function generates random values in the range:
0.0 ≤ ReturnVal ≤ 1.0.

The random value is formed from the nanoseconds of the current system time of the CPU. The byte order of this value is inverted and then converted to a floating point.

## Change log

Version & Date | Change description
--- | ---
| 1.0.0 | Siemens Industry Online Support
| 27.01.2017 | First released version
| 1.0.1 | Siemens Industry Online Support
| 17.08.2018 | Upgrade: TIA V15 Update 2
| 1.0.2 | Siemens Industry Online Support
| 23.11.2018 | Upgrade: TIA V15.1
| 1.1.0 | Simatic Systems Support
| 13.11.2019 | Renamed from "LGF_RandomBasic" to "LGF_Random_Real" Regions, comments and constants are added
| 3.0.0 | Simatic Systems Support
| 23.04.2020 | Set version to V3.0.0, harmonize the version of the whole library
| 3.0.1 | Simatic Systems Support
| 04.02.2021 | Insert documentation