Web lists-archives.org

Re: [Mingw-msys] [mingw - MSYS] Bison for MSYS




Michael Chen wrote:

> So I should always add 0.5 to pow() and modf() as shown, when my input
> parameters and output are all integers?

That, or use an explicit rounding function such as round().  The problem
is that the C language specifies that simply casting a double or float
to an integer, as you do with "(int)pow(L,D)", does not do any rounding
-- it simply discards the fractional parts.  So you should never use a
cast where you want something rounded to the nearest integer.

Brian

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Mingw-msys mailing list
Mingw-msys@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/mingw-msys