返回信息流cout << (unsigned)(-100.0) << endl; // 输出0
double f = -100.0;
cout << (unsigned)(f) << endl; // 输出4294967196
求教,负浮点数转unsigned,是个什么逻辑?
这是一条镜像帖。来源:北邮人论坛 / cpp / #94146同步于 2016/12/1
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
强制类型转换
xiaobing307
2016/12/1镜像同步2 回复
订阅后,新回复会通过你的通知中心匿名送达。
2 条回复
C++11 4.9 Floating-integral conversions
A prvalue of a floating point type can be converted to a prvalue of an integer type. The conversion truncates; that is, the fractional part is discarded. The behavior is undefined if the truncated value cannot be represented in the destination type.
顶暖神,好多单词不会。
【 在 nuanyangyang (暖羊羊) 的大作中提到: 】
: C++11 4.9 Floating-integral conversions
: A prvalue of a floating point type can be converted to a prvalue of an integer t...