【发布时间】:2016-10-20 07:33:03
【问题描述】:
unsigned long get_long(); //returns some crazy large unsigned long
int i;
i = get_long() % 20;
右侧的值应始终大到足以放入整数,因为可能的值只有 {0, 1, 2 .... 18, 19}。
我可以假设编译器可以将右侧的unsigned long 转换为左侧的整数吗?
【问题讨论】:
-
什么是
get_long?它不是标准功能。见How to Ask -
big enough to fit into an integer...什么? -
@WeatherVane 格式不正确。
-
get_long() 只是返回无符号长整数的函数的任意原型。
-
启用编译器警告 (
-Wall -Wextras -Wconversions) 看看。
标签: c types implicit-conversion