Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!tut.cis.ohio-state.edu!pacific.mps.ohio-state.edu!ohstpy!miavx1!miamiu!rhmcsupv From: RHMCSUPV@MIAMIU.BITNET (Douglas M. MacFarlane) Newsgroups: comp.lang.c Subject: Rounding in C Message-ID: <90247.233725RHMCSUPV@MIAMIU.BITNET> Date: 5 Sep 90 04:37:25 GMT Organization: Miami University - Academic Computer Service Lines: 33 Thanks to all who posted responses and e-mailed me directly on my assinging values to type float question. They were most appreciated. Microsoft C ver 5.1 required an explicit cast (ugh or yuk from some of you) i.e.: fValue = (float) 35 ; to remove the data conversion warning. Next question: Rounding fPrice = 1.35 ; fSpending = 10000 * fPrice ; printf ( "Spending is: %f", fSpending ) ; produces the output 13499.9997 instead of 13500 I seem to recall that these problems are inherent to computing, but a rounding function would do the trick. Has anyone written a RoundAFloat function that accepts a floating point value and the number of decimal places to round to ( 2 for round to 2 decimal places, -2 to round to the hundreds, etc.)? If so, could you send it to me, or post. Thanks Doug MacFarlane RHMCSUPV at miamiu.acs.muohio.edu