LINUX.ORG.RU

pow10 странное поведение


0

1

Программа:

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

#define _GNU_SOURCE

int main()
{
    double x;

    x = pow10(3.0);
    printf("3: %g\n", x);
//  printf("-3: %g\n", pow10(-3));
//  printf("4: %d\n", int(pow10(4)));
    printf("WTF\n");
    return 0;

Компилирую:

 gcc -Wall -oout ttt.c -lm

Что не так? Как добиться степени десятки от этой функции?

Выводит после 5сек ожидания:

5 seconds elapsed

% cat ttt.c
#include <stdio.h>
#include <math.h>

#define _GNU_SOURCE

int main()
{
    double x;

    x = pow10(3.0);
    printf("3: %g\n", x);
//  printf("-3: %g\n", pow10(-3));
//  printf("4: %d\n", int(pow10(4)));
    printf("WTF\n");
    return 0;
}
% gcc -Wall -oout ttt.c -lm
ttt.c: В функции «main»:
ttt.c:10:5: предупреждение: неявная декларация функции «pow10» [-Wimplicit-function-declaration]
ttt.c:10:9: предупреждение: несовместимая неявная декларация внутренней функции «pow10» [по умолчанию включена]
/% ./out 
3: 1000
WTF
anonymous
()

$ man pow10

DESCRIPTION
The pow10() function returns the value of 10 raised to the power x.

anonymous
()
Ответ на: комментарий от anonymous

А если define поставить перед инклюдами, то не будет и предупреждений.

anonymous
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.