From: "Steve Graegert" <graegerts@gmail.com>
To: linux-c-programming@vger.kernel.org
Subject: Re: Undefined reference to 'fmod'
Date: Sun, 11 Jun 2006 21:20:54 +0200 [thread overview]
Message-ID: <6a00c8d50606111220t3eeee679u8b6ef5b707fb6a59@mail.gmail.com> (raw)
In-Reply-To: <448C59BA.2090706@colannino.org>
On 6/11/06, James Colannino <james@colannino.org> wrote:
> Glynn Clements wrote:
>
> > No, fmod() is in libm, so you have to add -lm to the link command.
> >
> > As a general rule, anything which uses <math.h> has to link against
> > libm.
>
> Interesting. Compiling with the argument -lm fixed my problem. That
> leads me to another question: why are the functions found in math.h in a
> separate library? I would have thought that all functions found in the
> standard C library would be in glibc (The K&R book I'm reading said that
> math.h is a part of the standard library.)
The functions in libm allow to create portable programs with
well-defined and standard-compliant behavior, e.g. when numerical
errors occur, and provide the application with a means to control
their behavior in abnormal cases via the matherr callback.
Additionally, they almost never rely on the features specific to
processor architectures and are thus slower and sometimes slightly
less accurate than the functions from libc.
libc functions OTOH are written for speed and exploitation of
CPU-specific features; they do not call matherr, and are therefore
much faster and, due to the extended 80-bit precision with which the
Intel FPUs carry their calculations, sometimes more accurate.
\Steve
next prev parent reply other threads:[~2006-06-11 19:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-11 4:35 Undefined reference to 'fmod' James Colannino
2006-06-11 7:17 ` Steve Graegert
2006-06-11 7:18 ` Glynn Clements
[not found] ` <17547.46674.360830.637227@cerise.gclements.plus.com>
2006-06-11 17:58 ` James Colannino
2006-06-11 19:20 ` Steve Graegert [this message]
2006-06-14 15:41 ` James Stevenson
2006-06-15 0:20 ` Glynn Clements
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6a00c8d50606111220t3eeee679u8b6ef5b707fb6a59@mail.gmail.com \
--to=graegerts@gmail.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).