x/10.0 vs x*0.1

Mark A. Charette charette at edsews.EDS.COM
Fri Oct 14 12:52:59 AEST 1988


In article <13969 at mimsy.UUCP>, chris at mimsy.UUCP (Chris Torek) writes:
> In article <1700 at dataio.Data-IO.COM> Walter Bright suggests that one
> >>>Try very hard to replace divides with other operations, as in:
> >>>		x / 10
> >>>	with:
> >>>		x * .1
> 
> Yes (subject to the usual constraints, i.e., that you know what you are
> doing: if your input data has little precision, you can afford minor
> degredations in computations).

Some numerical analysts I associate with might argue that the propagation
of any error in floating point tends to be magnified as more operations
occur. I have had occasion to see the (small) precision in some data be
completely outweighed by using float instead of double (actually REAL
instead of DOUBLE PRECISION, but this is comp.lang.c ;') and really
whacking at the data (conversions back and forth between double and float).
 
> Yes (subject to the usual constraints, i.e., that you know what you are
> doing: 

Aye, there's the rub.


-- 
Mark Charette                   "On a clean disk you can seek forever" - 
Electronic Data Systems                  Thomas B. Steel Jr.
750 Tower Drive           Voice: (313)265-7006        FAX: (313)265-5770
Troy, MI 48007-7019       charette at edsews.eds.com     uunet!edsews!charette 



More information about the Comp.lang.c mailing list