首页 > 其他分享 >在算数运算中,能否将 bool 值 true 视作 1?

在算数运算中,能否将 bool 值 true 视作 1?

时间:2023-03-06 19:11:37浏览次数:37  
标签:false 运算 type bool 算数 true

true == 1;
true + 1; 

If the destination type is bool, see 4.12. If the source type is bool, the value false is converted to zero and the value true is converted to one.

在算数运算中 bool 类型会被提升成整型,true 会被转换成 1false 会被转换成 0

参考资料

标签:false,运算,type,bool,算数,true
From: https://www.cnblogs.com/revc/p/17185008.html

相关文章