setprecision 함수
글쓴이: ddoman / 작성시간: 화, 2008/01/22 - 5:11오전
#include iostream #include iomanip int main( int argc, char* argv[] ) { std::cout << std::setprecision( 0 ); std::cout << 2.5 << std::endl; std::cout << 3.5 << std::endl; std::cout << 4.5 << std::endl; std::cout << std::endl; std::cout << 2.49 << std::endl; std::cout << 2.51 << std::endl; std::cout << 3.51 << std::endl; return EXIT_SUCCESS; }
위 코드의 출력은
2 4 4 2 3 4
입니다. 이상하게도
출력이
3 4 5 2 3 4
가 아니더군요.
이유를 아시는분?
setprecision(0) 은 원래 정의되지 않았나요?
RHEL4( gcc-4.1.2, glibc-2.3.4 ) 에서 했습니다.
MS Windows XP( CodeWarrior 8 ) 에서도 같은 출력을 냅니다.
Forums:
댓글 달기