meta data for this page
  •  

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

Main site > LamaLibrary Simatic

lamaLibSimatic topics on lamaPLC


This page has been accessed for: Today: 1, Until now: 19