威纶通官方论坛

计算结果取整数的宏应该怎么写?

[复制链接]
发表于 2013-11-18 11:57:42 | 显示全部楼层 |阅读模式
比如:a=19,b=18
a/b的结果要取2.
这样的语EB8000和C一样吗?
该如何写?
发表于 2013-11-18 13:46:24 | 显示全部楼层
macro_command main()
unsigned short a[2],c
GetData(a[0], "Local HMI", LW, 0, 2)
c=a[0]/a[1]
if a[0]%a[1]>0 then
c=c+1
end if
SetData(c, "Local HMI", LW, 10, 1)
end macro_command

将LW0的值除以LW1,结果取整发送到LW10.
您需要登录后才可以发帖 登录 | 注册

本版积分规则

回复帖子

Archiver|小黑屋|威纶通官网 ( 粤ICP备06054553号 )

GMT+8, 2024-5-19 11:14

Powered by Discuz! X3.4

© 2001-2023 Comsenz Inc.

快速回复 返回顶部 返回列表