| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- ipfs singletone
- Java Call By Refernce
- kotiln functional interface
- Claude Intelij 연결
- spring mongoTemplate switch
- java 팩토리얼 개수
- mongodb lookup
- 자바 1676
- go
- rabbitmq 싱글톤
- java 1238
- kotiln const
- spring mongoTemplate
- 백준 2252 줄세우기
- spring mongodb switch
- 백준 1504 java
- 백준 연결요소 자바
- kotiln const val
- Spring ipfs
- javav 1676
- ipfs bean
- 자바 백준 팩토리얼 개수
- 익명 객체 @transactional
- spring mongodb
- java 파티
- nodejs rabbitmq
- java 1509
- 안정해시
- java 백준 1509
- 백준 특정한 최단 경로
Archives
- Today
- Total
공부 흔적남기기
Clion의 double 처리 실수 본문
728x90
반응형
d1과 d2는 0.001로 서로 같아보이지만
사실 자리수때문에 서로 아주 미세하게 다른값을 가지게된다.
근데 clion ide가 무조건 true라는 웃긴 스니펫을 보여줘서 남겨본다..

#include <iostream>
#include <cmath>
int main(){
using namespace std;
double d1 = (100 - 99.99);
double d2 = (10-9.99);
if(d1 == d2){
cout << "same" << endl;
} else{
cout << "different" << abs(d1-d2) << endl;
}
}728x90
반응형
'프로그래밍 언어 > c++ study' 카테고리의 다른 글
| 동적배열을 함수로 call하는 법 (0) | 2021.02.19 |
|---|---|
| c++ 동적배열과 이중포인터를 이용한 2차원 배열과 1차원배열을 이용한 2차원 배열! (0) | 2021.02.18 |