|
本帖最后由 yilye 于 2020-8-29 21:51 编辑
N=2 (N为需转化的小数位数:0,1,2,3......8 )
XX=ceil((floor((X*(10^(N+1)))/5,0))*5/(10^(N+1)),N)
IF XX>=1
XREF=ITOS(XX*10^N)
ENDIF
IF XX<1&XX>=0.1
XREF="0"+ITOS(XX*10^N)
ENDIF
IF XX<0.1&XX>=0.01
XREF="00"+ITOS(XX*10^N)
ENDIF
IF XX<0.01&XX>=0.001
XREF="000"+ITOS(XX*10^N)
ENDIF
IF XX<0.001&XX>=0.0001
XREF="0000"+ITOS(XX*10^N)
ENDIF
IF XX<0.0001&XX>=0.00001
XREF="00000"+ITOS(XX*10^N)
ENDIF
IF XX<0.00001&XX>=0.000001
XREF="000000"+ITOS(XX*10^N)
ENDIF
IF N==0
A=extract(XREF,1,(string_length(XREF)-N))+extract(XREF,(string_length(XREF)-(N-1)),N)
ELSE
A=extract(XREF,1,(string_length(XREF)-N))+"."+extract(XREF,(string_length(XREF)-(N-1)),N)
ENDIF
IF XX==0
A="0"
ENDIF
这个才能真正做到四舍五入. |
|