[LUGOS-PROG] ti math...

Metod Kozelj metod.kozelj at lugos.si
Tue Dec 5 08:36:50 CET 2006


Howdy!

Evo začetek man strani od round na moji mašini:

NAME
       round, roundf, roundl - round to nearest integer, away from zero

SYNOPSIS
       #include <math.h>

       double round(double x);
       float roundf(float x);
       long double roundl(long double x);

       Compile with -std=c99; link with -lm.

Zlasti zadnja vrstica je pomenljiva:

$ gcc -Wall -o test test.c
test.c: In function 'main':
test.c:6: warning: implicit declaration of function 'round'
test.c:6: warning: incompatible implicit declaration of built-in
function 'round'

med tem ko pri

$ gcc -Wall -std=c99 -o test test.c

ne javi ničesar ...

$ gcc --version
gcc (GCC) 4.1.2 20060901 (prerelease) (Debian 4.1.1-13)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Peace!
  Mkx

-- perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'
-- echo 16i[q]sa[ln0=aln100%Pln100/snlbx]sbA0D4D465452snlb xq | dc

------------------------------------------------------------------------

It were not best that we should all think alike; it is difference of opinion
that makes horse-races.
		-- Mark Twain, "Pudd'nhead Wilson's Calendar"



Miha Tomšič wrote:
> Hojla!
>
> Imam en problem in kup težav.
>
> Vzemimo test.c:
> ----------------
> #include <math.h>
> #include <stdio.h>
>
> int main(void)
> {
>        printf("%f, %f\n", 5.6, round(5.6));
>        return 0;
> }
> -----------------
>
> [pingo at localhost ~]$ gcc test.c -o test
> test.c: In function 'main':
> test.c:6: warning: incompatible implicit declaration of built-in
> function 'round'
> [pingo at localhost ~]$ ./test
> 5.600000, 6.000000
>
> Vse lepo in prav, če zanemarimo zgornje opozorilo. -lm ni potreben,
> ker uporabi kar vgrajeno funkcijo round().
>
> [pingo at localhost ~]$ gcc test.c -o test -fno-builtin -lm
> [pingo at localhost ~]$ ./test
> 5.600000, 76941697922011962845100419780797605609472.000000
>
> [pingo at localhost ~]$ gcc --version
> gcc (GCC) 4.1.1 20061011 (Red Hat 4.1.1-30)
>
> ---------------------
>
> Saj mogoče sem jaz malo usekan, ampak zadeva je podobno bizarna tudi
> na drugi mašini:
> # gcc test.c -o test -lm
> # ./test
> 5.600000, -0.000000
> # gcc --version
> 2.95.4
>
> A kdo vidi kje kakšno očitno napako? Problem se pojavlja še pri drugih
> matematičnih funkcijah (recimo sqrt()).
>
> Hvala in srečno, Miha
> ------------------------------------------------------------------------
>
> _______________________________________________
> lugos-prog mailing list
> lugos-prog at lugos.si
> http://liste2.lugos.si/cgi-bin/mailman/listinfo/lugos-prog
>   


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://liste2.lugos.si/pipermail/lugos-prog/attachments/20061205/8c88ed15/attachment.html


More information about the lugos-prog mailing list