home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!jvnc.net!princeton!csservices!kastle!blume
- From: blume@kastle.Princeton.EDU (Matthias Blume)
- Subject: Re: the abs() function in C
- Message-ID: <1992Nov21.015518.20743@csservices.Princeton.EDU>
- Sender: news@csservices.Princeton.EDU (USENET News System)
- Reply-To: blume@kastle.Princeton.EDU (Matthias Blume)
- Organization: Dept. of Computer Science, Princeton University
- References: <pebi.722223424@zephyr.aem.umn.edu> <maurer.722246649@magellan.stanford.edu>
- Date: Sat, 21 Nov 1992 01:55:18 GMT
- Lines: 23
-
- In article <maurer.722246649@magellan.stanford.edu>,
- maurer@nova.stanford.edu (Michael Maurer) writes:
- |> In <pebi.722223424@zephyr.aem.umn.edu> pebi@aem.umn.edu (Peter A.
- Bidian) writes:
- |>
- |>
- |> >Isn't abs(-2)=2 in C?
- |> >I always get 0.
-
- Please, show the full program text, where you encountered the problem.
- Of course, abs(-2) should be 2.
-
- |>
- |> >Confused!
- |>
- |> >Peter
- |>
- |> you probably want to say abs(-2.0), if the abs() function expects a
- |> floating point argument. or abs((double)-2).
-
- abs is an int-function! For doubles we've got fabs!
-
- -Matthias
-