c++ 判断两个double是否相等
2015-08-20 16:28
435 查看
#include <stdio.h> #include <iostream> #include<math.h> using namespace std; bool equal(double num1,double num2) { if((num1-num2>-0.000001)&&(num1-num2)<0.000001) return true; else return false; } int main() { double e; double f; e = 0.05-0.075; f= 0.025-0.05; if(equal(e,f)) { printf("%f\n%f",e,f); printf("="); }else { printf("%f\n%f",e,f); printf("!="); } system("pause"); }
相关文章推荐
- C++多线程编程入门1
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
- C++ Primer 学习笔记(第五章:语句)
- c语言实现约瑟夫环-每隔几个删除一个,求剩下的
- C++中的 Round(),floor(),ceil()
- c++ const_cast 前置与后置++
- C语言-bubblesort
- C++指针探讨 (四) 函数对象
- poj1580 String Matching (枚举,gcd)
- C++ 所有动作是否都由main引起
- 论指针的类型用处
- c++中32位64位操作系统基本数据类型字节大小
- C++ volatile
- C++ Assert
- 使用C++实现SDK之WebBrowser容器
- Windows下使用静态库
- C++ Primer 5e chapter 5
- C语言项目:学生成绩管理系统
- Windows下创建静态库
- Auto Variables