只用來顯示和位置賦值,四舍五入的話偏差會比較大 位置到達還是用指令的Done標志
//將當前位置賦值給臨時變量
temp:=IN_當前位置;
//連乘小數(shù)位位數(shù)
FOR i:=1 TO 保留小數(shù)點位數(shù) BY 1 DO
temp:=temp*10.0;
END_FOR;
//先轉(zhuǎn)換成整型除去剩余小數(shù),再轉(zhuǎn)換成浮點數(shù)
temp:=DINT_TO_REAL(REAL_TO_DINT(temp));
//連除獲取保留設(shè)定小數(shù)點位數(shù)的浮點數(shù)
FOR i:=1 TO 保留小數(shù)點位數(shù) BY 1 DO
temp:=temp/10.0;
END_FOR;
OUT_當前位置:=temp;