A power of 10 (10 X) is any of the integer powers of the number ten; in other words, ten multiplied by itself a certain number of times. By definition, the number one is a power (the zeroth power) of ten.
FUNCTION "powerOfTen" : REAL { S7_Optimized_Access := 'TRUE' } VERSION : 0.1 VAR_INPUT power : REAL; // 10^power END_VAR VAR_TEMP COUNT : INT; out : REAL; i : INT; END_VAR BEGIN // void := 10 ^ power // A power of 10 is any of the integer powers of the number ten; in other words, // ten multiplied by itself a certain number of times (when the power is a positive integer). #out := 1.0; IF #power > 0.0 THEN // positive power #count := REAL_TO_INT(#power); FOR #i := 0 TO #count DO #out := #out * 10.0; END_FOR; END_IF; IF #power < 0.0 THEN // negative power #count := REAL_TO_INT(#power * -1.0) ; FOR #i := 0 TO #count DO #out := #out / 10.0; END_FOR; END_IF; // output #powerOfTen := #out; END_FUNCTION
Main site > LamaLibrary Simatic
Page | Date | User | Tags |
---|---|---|---|
2024/11/18 21:23 | Sandor Vamos | tia, scl, lamalibsimatic, source code, energy meter, modbus, register, word | |
2024/11/18 20:36 | Sandor Vamos | tia, scl, lamalibsimatic, source code, energy meter, modbus, register, word | |
2024/11/18 20:22 | Sandor Vamos | tia, scl, lamalibsimatic, source code, join, bits, byte, convert | |
2024/11/18 19:54 | Sandor Vamos | tia, scl, lamalibsimatic, source code, math, power of 10 |
This page has been accessed for: Today: 2, Until now: 20