xor*_*xor 2 c++ c-preprocessor
所以我定义..
#define RADIAN(x) x*3.14159265f/180.0f
Run Code Online (Sandbox Code Playgroud)
然后像这样使用它:
RADIAN(theta-90)
Run Code Online (Sandbox Code Playgroud)
我的程序经常给我不正确的结果,我花了几个小时才意识到上述声明和下面的声明之间存在巨大差异.
RADIAN((theta-90))
Run Code Online (Sandbox Code Playgroud)
现在我的程序运行得很好.为什么第一个陈述不正确?
#define只做文本替换,所以RADIAN(theta-90)真的theta-90*3.14159265f/180.0f,显然不是你的意思.尝试
#define RADIAN(x) ((x)*3.14159265f/180.0f)
Run Code Online (Sandbox Code Playgroud)
代替.
| 归档时间: |
|
| 查看次数: |
936 次 |
| 最近记录: |