本文介绍了做负数在C / C返回false ++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在评估整数在C / C ++布尔都是负数真的还是假的?难道他们总是真/假,无论编译器?


解决方案

所有非零值将被转换为真正和零值。随着负数为非零,它们都转换为真正

从C ++ 11标准(重点煤矿)报价:


You will only get the above guarantee when your compiler is standards-compliant, or at least, complies with this specific part of the standard. In practice, all compilers have this standard behavior, so there isn't much to worry about.

这篇关于做负数在C / C返回false ++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-22 20:30