当前位置:网站首页>浮点数如何与0进行比较?
浮点数如何与0进行比较?
2022-07-04 13:31:00 【北冥有鱼丶丶】
浮点数类型的变量与0的比较我们通常采取下面这种方式
//先定义一个值极小的宏
#define ESP 0.00000000000000001
//1.判断是否等于0
//然后将浮点数与0.0差值的绝对值与该极小值进行比较
//如果浮点数与0.0差值的绝对值小于该极小值,那么我们就认为浮点数等于0.0
float a = 0.0f;
scanf("%f",&a);
if(fabs(a - 0.0) < ESP)
{
//那么fabs(a - 0.0) == 0
//即a - 0.0的绝对值为0
//即a = 0.0
}
//2.判断是否大于0
if(a >= ESP)
//那么a大于0
边栏推荐
- An overview of 2D human posture estimation
- Quick introduction to automatic control principle + understanding
- What are the concepts of union, intersection, difference and complement?
- LVGL 8.2 Draw label with gradient color
- Docker compose public network deployment redis sentinel mode
- Test evaluation of software testing
- [MySQL from introduction to proficiency] [advanced chapter] (IV) MySQL permission management and control
- 炒股网上开户安全吗?会不会被骗。
- C language achievement management system for middle school students
- Summary of common problems in development
猜你喜欢

UFO: Microsoft scholars have proposed a unified transformer for visual language representation learning to achieve SOTA performance on multiple multimodal tasks

Transplant tinyplay for imx6q development board QT system

Redis publish and subscribe

IO流:节点流和处理流详细归纳。

IO flow: node flow and processing flow are summarized in detail.
![leetcode:6110. The number of incremental paths in the grid graph [DFS + cache]](/img/48/56ed03b21709a97fd55c8cccf98092.png)
leetcode:6110. The number of incremental paths in the grid graph [DFS + cache]

内存管理总结

Combined with case: the usage of the lowest API (processfunction) in Flink framework

5g TV cannot become a competitive advantage, and video resources become the last weapon of China's Radio and television

Redis 發布和訂閱
随机推荐
Scratch Castle Adventure Electronic Society graphical programming scratch grade examination level 3 true questions and answers analysis June 2022
LVGL 8.2 Line
Five minutes of machine learning every day: how to use matrix to represent the sample data of multiple characteristic variables?
Classify boost libraries by function
C language book rental management system
LVGL 8.2 Menu
韩国AI团队抄袭震动学界!1个导师带51个学生,还是抄袭惯犯
LVGL 8.2 Draw label with gradient color
EventBridge 在 SaaS 企业集成领域的探索与实践
[C language] Pointer written test questions
Expose Ali's salary and position level
Cann operator: using iterators to efficiently realize tensor data cutting and blocking processing
LVGL 8.2 Menu
对话龙智高级咨询顾问、Atlassian认证专家叶燕秀:Atlassian产品进入后Server时代,中国用户应当何去何从?
No servers available for service: xxxx
Digi XBee 3 rf: 4 protocols, 3 packages, 10 major functions
Redis publier et s'abonner
LVGL 8.2 List
LVLG 8.2 circular scrolling animation of a label
深度学习7 Transformer系列实例分割Mask2Former