Floating point rounding instruction

Also known as floating-point real number (Real), in STEP 7, expressed as a decimal floating-point number. I read some people say for S7-300 / 400 "ROUND instruction is actually round 6 into 5, if you really want to shed 5 into 4, you can add pre-0.1."

    
To be honest I have not noticed this last instruction details. To this end first consult the online help instructions:


    
"ROUND (rounded to a long integer) IN parameter content to read floating-point number and converts it to a double integer (32-bit) result to the nearest integer (rounded to the nearest value). If the float interposed between two integers, the even number is returned. the results output by the parameter OUT. "


    
We called "rounding to nearest" to rounding. Here are the results of simulation experiment, rounding it seems, there is no 5 round 6 into the problem.


    
2.49999 input, output 2 
    
2.50001 input, output 3 


    
Float just returned even between two integers, which is our habits, it may be five shekels, five may enter. The simulation results are as follows:


    
1.5 input (between 1 and 2), the output is 2 
    
Input (between 2 and 3) 2.5, the output is 2 


    
Siemens official documents (including software help files) is the basis of our study, we also need to deeply understand the hands-on experiments.


    
Note that the floating-point input allows a maximum six significant digits.


评论

此博客中的热门博文

RVNet-S7300 PPI MPI DP To Ethernet Gateway Protocol Converter Module

Profinet Bus IO Temperature Acquisition Module

Ethernet or WiFi Communication Module for Siemens SMART S7-200