|
Format的用法(3) Format('this is %-4d,yes',[12]); 输出是:this is 12 ,yes ["." prec] 指定精度,对于浮点数效果最佳: Format('this is %.2f',['1.1234]); 输出 this is 1.12 Format('this is %.7f',['1.1234]); 输了 this is 1.1234000 而对于整型数,如果prec比如整型的位数小,则没有效果 反之比整形值的位数大,则会在整型值的前面以0补之 Format('this is %.7d',[1234]); 输出是:this is 0001234] 对于字符型,刚好和整型值相反,如果prec比字符串型的长度大 则没有效果,反之比字符串型的长度小,则会截断尾部的字符 Format('this is %.2s',['1234']); 输出是 this is 12 而上面说的这个例子: Format('this is %e',[-2.22]); 返回的是:this is -2.22000000000000E+000 怎么去掉多余的0呢,这个就行啦 Format('this is %.2e',[-2.22]);
|