printf() 관련 질문입니다.

neon20의 이미지

#include<stdio.h>
#include<math.h>

int main(){
        double sq,p;

        sq = sqrt((double)9);
        p = pow(5,2);

        printf("sq = %g, p = %g\n",sq,p);

        return 0;
}

예상 결과 : sq = 3, p = 25 인데 답은 엉뚱하게

실제 결과 : sq = 5.4163e-315, p = 5.30758e-315 이렇게 나오네요.

이유가 뭔가요..ㅜㅜ? 참고로 현재 리눅스 서버에서 컴파일 중입니다.

kernuts의 이미지

[kernuts@localhost work]$ ls
a.out  test.c
[kernuts@localhost work]$ ./a.out
sq = 3, p = 25
[kernuts@localhost work]$

저 소스 그대로 했는데 제대로 나오네요...

The knowledge belongs to the World like Shakespear's and Asprin.