====== lamaLibrary: Power of 10 ======
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
{{:download:poweroften.scl|Power of 10 (SCL) Download}}
Main site > [[simatic:lamalib|LamaLibrary Simatic]]
===== lamaLibSimatic topics on lamaPLC =====
{{topic>lamaLibSimatic}}
{{tag>TIA SCL lamaLibSimatic source_code math power_of_10}}
\\
This page has been accessed for: Today: {{counter|today}}, Until now: {{counter|total}}