Do you need to transform the Real Number Parameter to a String Parameter?
It is easy with Relations:
The input parameter: X=12.34567 (Real Number)
The output parameter: Y=1.234 (String)
Write into Relations: Tools>Relations…
/* Number of Digits
ND = 3
/* Rounded Number
RN = FLOOR((X+(5/10^(ND+1))),ND)
/* String Output – No Leading Zero
Y = ITOS(FLOOR(RN))+”.”+EXTRACT(ITOS((RN-FLOOR(RN)+1)*10^(ND)),2,ND)
- To get a zero before the decimal point for values less than one, a conditional statement is required:
/* String Output With Leading Zero
IF FLOOR(RN) == 0
Y = “0.”+EXTRACT(ITOS((RN-FLOOR(RN)+1)10^(ND)),2,ND) ELSE Y = ITOS(FLOOR(RN))+”.”+EXTRACT(ITOS((RN-FLOOR(RN)+1)10^(ND)),2,ND)
ENDIF
Comments are closed