Description
You can use the "Generate next higher integer from floating-point number" instruction to round the value at input IN to the next higher integer. The instruction interprets the value at input IN as a floating-point number and converts this to the next higher integer. The result of the instruction is output at the OUT output and can be queried there. The output value can be greater than or equal to the input value.
The enable output ENO has the signal state "0" if one of the following conditions applies:
-
Enable input EN has the signal state "0".
-
Errors, such as an overflow, occur during execution.
Parameters
The following table shows the parameters of the instruction "Generate next higher integer from floating-point number":
|
Parameters |
Declaration |
Data type |
Memory area |
Description |
|
|---|---|---|---|---|---|
|
S7-1200 |
S7-1500 |
||||
|
EN |
Input |
BOOL |
I, Q, M, D, L or constant |
I, Q, M, D, L, T, C or constant |
Enable input |
|
ENO |
Output |
BOOL |
I, Q, M, D, L |
I, Q, M, D, L |
Enable output |
|
IN |
Input |
Floating-point numbers |
I, Q, M, D, L, P or constant |
I, Q, M, D, L, P or constant |
Input value as floating-point number |
|
OUT |
Output |
Integers, floating-point numbers |
I, Q, M, D, L, P |
I, Q, M, D, L, P |
Result with the next higher integer |
You can select the data types of the instruction from the "???" drop-down lists of the instruction box.
For additional information on valid data types, refer to "See also".
Example
The following example shows how the instruction works:
The following table shows how the instruction works using concrete operand values:
|
Parameters |
Operand |
Value |
|
|---|---|---|---|
|
IN |
TagIn_Value |
0.50000000 |
-0.50000000 |
|
OUT |
TagOut_Value |
1 |
0 |
If the "TagIn" operand has signal state "1", the instruction is executed. The floating-point number at input "TagIn_Value" is rounded to the next higher integer and sent to output "TagOut_Value". If the instruction is executed without errors, the "TagOut" output is set.