首页
Java
登录
6mi
u
盘
搜
搜 索
Java
With 2 decimals: %1.2f<br >With no decimals: %1u",$number
With 2 decimals: %1.2f<br >With no decimals: %1u",$number
xiaoxiao
2021-02-28
93
printf("With 2 decimals: %1.2f<br />With no decimals: %1u",$number); 把number的值也就是123替换在%的位置,%1表示用第一个参数替换,%2用第二个,类推。.2f 表示用两位小数的浮点数的格式。所以第一个显示为 123.00后面一个 %1u 表示用非小数的方式显示第一个参数。所以显示为 123. 如果number=123.456, 那么这里仍然为 123.
转载请注明原文地址: https://www.6miu.com/read-45823.html
技术
最新回复
(
0
)