将实数赋值给以 I 开头的变量是否会转换为整数?
将实数赋值给以 I 开头的变量是否会转换为整数?
real vx;
vx = 2.59808
ix = vx
ix == 2 吗?
Does an assignment of a real to a variable starting with I convert to integer?
real vx;
vx = 2.59808
ix = vx
is ix == 2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,类型会自动转换。
关闭这种容易出错的行为
您可以通过指定“implicit none”语句强制程序员声明所有变量来 。 否则,类型将是隐式的,并且以 i 开头的变量将是整数类型。
As far as I know the type will be automatically converted.
You can turn of this error-prone behavior by specifying
The "implicit none" statement forces the programmer to declare all variables. Otherwise the types will just be implicit and variables starting with
i
will be of type integer.据我所知,你需要将实数转换为整数。
但我不确定您的语言是否允许。
as far as i know you need to cast real into integer.
but i not sure, if it is allowed in your language.