home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!spool.mu.edu!agate!doc.ic.ac.uk!mrccrc!warwick!coventry!champion
- From: champion@cch.coventry.ac.uk (Alun)
- Subject: Re: Rounding floats to integers
- Message-ID: <BxM0Eu.DxL@cck.coventry.ac.uk>
- Sender: news@cck.coventry.ac.uk (news user)
- Nntp-Posting-Host: cc_sysh
- Organization: Coventry University, Coventry, UK.
- References: <rfries.123@sceng.ub.com> <BxJx0s.6q8@cck.coventry.ac.uk> <BxK7xK.7Ap@sci.kun.nl>
- Date: Thu, 12 Nov 1992 15:30:29 GMT
- Lines: 29
-
- In article <BxK7xK.7Ap@sci.kun.nl> hansm@cs.kun.nl (Hans Mulder) writes:
- ~In <BxJx0s.6q8@cck.coventry.ac.uk> champion@cch.coventry.ac.uk (Alun) asks:
- ~
- ~>int round(float n)
- ~>{
- ~> if(n < 0)
- ~> return (int)(n - 0.5);
- ~> return (int)(n + 0.5); // Doesn't the function do the cast automatically
- ~>}
- ~
- ~In C the fact that the function is declared to return an int makes the casts
- ~redundant. I don't know about C++ (or whatever language it is that you use).
- ~Go and ask in the relevant group, if you really want to know. Or look it up
- ~in a book.
-
- This *is* C my apologies for the misleading comment.
- The comment should of been.
-
- /* Doesn't the function do the cast automatically ?? */
-
- You answered my question anyway.
-
- Cheers
-
- -Alun
-
- --
- A.Champion | That's an interesting point, in the sense of
- (champion@uk.ac.cov.cck) | being very not interesting at all. - The Liar
-