文本Ctrl->在 Erlang 中截断浮点数
我的最后一个问题让我想到了这个:
wxTextCtrl:setValue( TcGrossProfit, io_lib:format("~.2f",[NewGrossProfit])),
从 wxTextCtrl 生成一个错误,参数错误。
我知道这是罪魁祸首
NewGrossProfit = 5.45333,
io_lib:format("~.2f",[NewGrossProfit])
感谢最后一个,希望这个更容易
-B
编辑
最后一个问题: 在 Erlang 中截断浮点数
My last question leads me to this one:
wxTextCtrl:setValue( TcGrossProfit, io_lib:format("~.2f",[NewGrossProfit])),
generates an error from wxTextCtrl, with a bad arg.
I know this is the culprit
NewGrossProfit = 5.45333,
io_lib:format("~.2f",[NewGrossProfit])
Thanks for the last one, hope this one's easier
-B
EDIT
Last Question:
Truncate a float in Erlang
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是
io_lib:format("~.2f",[NewGrossProfit])
返回一个 iolist:["5.45"]
,但是wxTextCtrl:setValue< /code> 似乎需要一个字符串(
"5.45"
)。所以应该有效。
The problem is that
io_lib:format("~.2f",[NewGrossProfit])
returns an iolist:["5.45"]
, butwxTextCtrl:setValue
seems to need a string ("5.45"
). Soshould work.