06-BOOL类型的使用

BOOL类型的使用(C语言中没有BOOL类型)

1、BOOL类型的本质

  BOOL类型的本质其实是整型,它的两个取值YESNO分别可以用10来表示。

  宏观上:YES表示非零,NO表示零;

  微观上:YES表示1,NO表示0。

  typedef signed char BOOL

2、BOOL类型有两种取值:YESNO

#define YES (BOOL)1

#define NO  (BOOL)0

3、BOOL的输出(当做整数来输出)

 1 NSLog(@"%d %d", YES, NO); 

4、编写代码如下:

 

 1 #import <Foundation/Foundation.h>
 2 //BOOL做返回值类型,函数功能是返回一个NO
 3 BOOL test(BOOL mybool)
 4 {
 5     return NO;
 6 }
 7         
 8 int main(int argc, const char * argv[])
 9 {
10     BOOL b = YES;            
11     BOOL b2 = NO;            
12     BOOL b3 = 1; // YES            
13     BOOL b4 = 0; // NO
14                         
15     NSLog(@"b = %d", b);//结果为b = 1
16     NSLog(@"b2 = %d", b2);//结果为b2 = 0
17     NSLog(@"b3 = %d", b3);//结果为b3 = 1
18     NSLog(@"b4 = %d", b4);//结果为b4 = 0
19     NSLog(@"%d", test(YES));//结果为0
20     return 0;
21 }

 

本节重点:

  1、BOOL类型的本质其实是整型,它的两个取值YESNO分别可以用10来表示。

    typedef signed char BOOL

  2、BOOL类型有两种取值:YESNO。  

  3、BOOL的输出(当做整数来输出)。

    

 

 

 

 

转载于:https://www.cnblogs.com/xdl745464047/p/3995797.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
06/06/2023-16:31:47] [TRT] [I] [MemUsageChange] TensorRT-managed allocation in IExecutionContext creation: CPU +0, GPU +0, now: CPU 0, GPU 0 (MiB) /home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/tensorrt/__init__.py:166: FutureWarning: In the future `np.bool` will be defined as the corresponding NumPy scalar. bool: np.bool, Traceback (most recent call last): File "/home/sniper/anaconda3/envs/labelme/bin/yolo", line 8, in <module> sys.exit(entrypoint()) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/ultralytics/yolo/cfg/__init__.py", line 398, in entrypoint getattr(model, mode)(**overrides) # default args from model File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/ultralytics/yolo/engine/model.py", line 302, in val validator(model=self.model) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/ultralytics/yolo/engine/validator.py", line 114, in __call__ model = AutoBackend(model, device=self.device, dnn=self.args.dnn, data=self.args.data, fp16=self.args.half) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/ultralytics/nn/autobackend.py", line 174, in __init__ dtype = trt.nptype(model.get_binding_dtype(i)) File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/tensorrt/__init__.py", line 166, in nptype bool: np.bool, File "/home/sniper/anaconda3/envs/labelme/lib/python3.8/site-packages/numpy/__init__.py", line 305, in __getattr__ raise AttributeError(__former_attrs__[attr]) AttributeError: module 'numpy' has no attribute 'bool'. `np.bool` was a deprecated alias for the builtin `bool`. To avoid this error in existing code, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here. The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations 如何修复
06-07

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值