c++数据类型之uint8_t/uint16_t/uint32_t/float128_t

最近在读代码的时候,遇到了一些数据类型,不太理解是什么意思,于是开始在网上找答案,特此记录一下。

头文件

“stdint.h”

/* There is some amount of overlap with <sys/types.h> as known by inet code */
#ifndef __int8_t_defined
# define __int8_t_defined
typedef signed char             int8_t; 
typedef short int               int16_t;
typedef int                     int32_t;
# if __WORDSIZE == 64
typedef long int                int64_t;
# else
__extension__
typedef long long int           int64_t;
# endif
#endif
 
/* Unsigned.  */
typedef unsigned char           uint8_t;
typedef unsigned short int      uint16_t;
#ifndef __uint32_t_defined
typedef unsigned int            uint32_t;
# define __uint32_t_defined
#endif
#if __WORDSIZE == 64
typedef unsigned long int       uint64_t;
#else
__extension__
typedef unsigned long long int  uint64_t;
#endif

现在就知道了标题中的数据类型是什么意思,但是只是只有int相关的类型,没有float相关的类型,我也没有找到相关的头文件,但是我找到了他们分别是怎么类型的了,如下:

typedef float float32_t;
typedef long double        float64_t;
typedef long double        float128_t;

所以,只要加入这两个typedef就可以了。
还有就是,float64_tfloat128_t我找到的类型解释都是long double,我也觉得很奇怪,如果有知道的小伙伴可以在评论区留言。




参考链接:**https://blog.csdn.net/nei504293736/article/details/101060693**
float和uint8_t是两种不同的数据类型float是单精度浮点数类型,用于表示带有小数部分的实数。它在内存中占用4个字节,可以表示较大的数值范围和较高的精度。 而uint8_t是无符号8位整数类型,用于表示范围在0到255之间的整数。它在内存中占用1个字节,不能表示负数。uint8_t实际上是一个char类型,所以输出uint8_t类型的变量时,实际上输出的是对应的字符,而不是数值。 总结来说,float适用于需要表示小数的情况,而uint8_t适用于需要表示范围在0到255之间的整数的情况。它们在内存占用和数值范围上也有所不同。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [uint8_t、uint16_t、uint32_t、uint64_t](https://blog.csdn.net/qq_44915792/article/details/124759521)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [c++数据类型之uint8_t/uint16_t/uint32_t/float128_t](https://blog.csdn.net/weixin_50749380/article/details/124014096)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

5436649486

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值