小数位判断,如何自动判断保留几位小数?

ahcorelax 2014-03-10 02:56:00
if (( mprecords_currentoutqty - round( mprecords_currentoutqty,0) = 0.00),"#,##0","#,##0,##")

如上,在数据窗口中我想设置某列当该列取整的值等于该列的值,则显示格式为"#,##0";
否则的话显示为"#,##0,##"

但我实际测试发现没有达到我想要的效果,不知道各位有没有碰到过类似的问题,如何解决的?

...全文
392 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
sjlion 2014-03-11
  • 打赏
  • 举报
回复
引用 2 楼 ahcorelax 的回复:
非常感谢,经测试,原始是我无意中将.输入为,导致的错误; 正确表达式应为:if (( mprecords_currentoutqty - round( mprecords_currentoutqty,0) = 0.00),"#,##0","#,##0.##") 这个是我目前想到的对于小数位的处理办法,但是不通用,不知道各位有没有更好的办法?
既然这个没问题,你需要通用的话,就动态修改表达式好了
zhangyangziwo 2014-03-11
  • 打赏
  • 举报
回复
没这么智能,我们的小数位都是固定死的,如果想显示不同的小数位,就修改pbl。
zlf19810306 2014-03-11
  • 打赏
  • 举报
回复
如果mprecords_currentoutqty列是双精度类型(Double)可能会有问题,你要先处理一下round一下
zlf19810306 2014-03-11
  • 打赏
  • 举报
回复
if (mprecords_currentoutqty = int(mprecords_currentoutqty ),'###,##0','###,##0.00') if (mprecords_currentoutqty - int(mprecords_currentoutqty ) = 0.00,'###,##0','###,##0.00')
zlf19810306 2014-03-11
  • 打赏
  • 举报
回复
这样写 if (mprecords_currentoutqty = int(mprecords_currentoutqty ),'###,##0','###,##0.00') 或者是 if (( mprecords_currentoutqty - int( mprecords_currentoutqty,0) = 0.00),"#,##0","#,##0.##")
ahcorelax 2014-03-10
  • 打赏
  • 举报
回复
非常感谢,经测试,原始是我无意中将.输入为,导致的错误; 正确表达式应为:if (( mprecords_currentoutqty - round( mprecords_currentoutqty,0) = 0.00),"#,##0","#,##0.##") 这个是我目前想到的对于小数位的处理办法,但是不通用,不知道各位有没有更好的办法?
WorldMobile 2014-03-10
  • 打赏
  • 举报
回复
引用 楼主 ahcorelax 的回复:
if (( mprecords_currentoutqty - round( mprecords_currentoutqty,0) = 0.00),"#,##0","#,##0,##") 如上,在数据窗口中我想设置某列当该列取整的值等于该列的值,则显示格式为"#,##0"; 否则的话显示为"#,##0,##" 但我实际测试发现没有达到我想要的效果,不知道各位有没有碰到过类似的问题,如何解决的?
#,##0,##应该为#,##0.##或者#,##0.0#

609

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder DataWindow
社区管理员
  • DataWindow社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧