26.10.2012 Views

Statement List (STL) - DCE FEL ČVUT v Praze

Statement List (STL) - DCE FEL ČVUT v Praze

Statement List (STL) - DCE FEL ČVUT v Praze

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Conversion Instructions<br />

3.16 TRUNC Truncate<br />

Format<br />

Description<br />

Status word<br />

Example<br />

TRUNC<br />

TRUNC (conversion of a 32-bit IEEE floating-point number to 32-bit integer)<br />

interprets the contents of ACCU 1 as a 32-bit IEEE floating-point number. The<br />

instruction converts the 32-bit IEEE floating-point number to a 32-bit integer (double<br />

integer). The result is the whole number part of the floating-point number to be<br />

converted (IEEE rounding mode "round to zero"). If the number is out of the<br />

permissible range, then the status bits OV and OS are set to 1. The result is stored in<br />

accumulator 1.<br />

Conversion is not performed and an overflow indicated in the event of a fault<br />

(utilization of a NaN or a floating-point number that cannot be represented as a 32-bit<br />

integer number).<br />

BR CC 1 CC 0 OV OS OR STA RLO /FC<br />

writes: - - - x x - - - -<br />

<strong>STL</strong> Explanation<br />

L MD10 //Load the floating-point number into ACCU 1-L.<br />

TRUN //Convert the floating-point number (32-bit, IEEE-FP) to an integer (32-bit)<br />

C<br />

and round result. Store the result in ACCU 1.<br />

T MD20 //Transfer result (double integer number) to MD20.<br />

Value before conversion Value after conversion<br />

MD10 = "100.5" => TRUNC => MD20 = "+100"<br />

MD10 = "-100.5" => TRUNC => MD20 = "-100"<br />

<strong>Statement</strong> <strong>List</strong> (<strong>STL</strong>) for S7-300 and S7-400 Programming<br />

3-16 A5E00706960-01

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!