반응형
float 대신 실제로 이기 때문에,
- <cmath> 헤더를 사용.
- roundf 함수는 float를 처리하는 함수.
- C++에서 round를 더 많이 쓰이게 됨.
#include <iostream>
#include <cmath>
int main() {
float num = 3.14;
float roundedNum = round(num);
std::cout << "Original number: " << num << std::endl;
std::cout << "Rounded number: " << roundedNum << std::endl;
return 0;
}
[C++] round 반올림 함수에 대해서.
안녕하세요! BlockDMask 입니다.오늘은 C++11에 추가된 반올림함수 round에 대해서 이야기해보려 합니다.(C언어/C++ 올림함수 ceil, 내림함수 floor가 궁금하다면 [바로가기] 이쪽에 포스팅이 있습니다.)(C+
blockdmask.tistory.com
반응형