Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- C++
- autonomous vehicle
- GIT
- 동적라이브러리
- Recursion
- C
- 선형대수
- GNN
- Leetcode
- 수치최적화
- CUDA
- Motion Planning
- Hybrid A star
- OSQP
- Frenet Coordinate
- 정적라이브러리
- path planning
- Graph Neural Network
- MDP
- 소프티어
- DynamicProgramming
- 경로생성
- Dubins Path
- 백준
- CPP
- 강화학습
- 공유라이브러리
- self driving car
- PathPlanning
- solver
Archives
- Today
- Total
Swimmer
[백준] A/B, 1008, C 본문
- 포인트
- 부동 소수점에 대해 이해하고 있나?
- float32_t (4byte), float64_t (8byte)의 연산 결과 차이를 알고 있나?
#include <stdio.h>
// 포인트
// 8byte 자료형을 사용하면 10-9 자릿수까지 정확하게 표현가능
// 4byte 자료형 사용 시, 10-8 자릿수부터 연산 결과 이상해짐
// 4byte -> 32bit, 1bit 는 부호, 8bit 는 지수(소숫점), 23bit는 가수
// 이 방식은 IEEE에서 표준으로 제안한 방식 (IEEE 754 Standard for Floating-Point Arithmetic)
typedef long int int64_t;
typedef double float64_t;
typedef int int32_t;
typedef float float32_t;
int main()
{
int64_t s64_1stVal = 0, s64_2ndVal = 0;
float64_t f64_1stVal = 0.0f, f64_2ndVal = 0.0f;
float64_t f64_RetVal = 0.0f;
while (1)
{
scanf_s("%d", &s64_1stVal);
scanf_s("%d", &s64_2ndVal);
f64_1stVal = (float64_t)s64_1stVal;
f64_2ndVal = (float64_t)s64_2ndVal;
printf_s("%f \n", f64_1stVal);
printf_s("%f \n", f64_2ndVal);
f64_RetVal = f64_1stVal / f64_2ndVal;
printf_s("%.10f \n", f64_RetVal);
}
}
'코딩 문제' 카테고리의 다른 글
[백준] 유기농 배추, 1012, C (0) | 2022.11.28 |
---|---|
[백준] 다리놓기, 1010, C (0) | 2022.11.25 |
[백준] 행렬 덧셈, 2738, C (0) | 2022.11.21 |
[백준] 알람 시계, 2884, C/C++ (0) | 2022.11.20 |
[백준] 곱셈, 2588, C/C++ (0) | 2022.11.19 |
Comments