Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!henry From: henry@utzoo.UUCP (Henry Spencer) Newsgroups: net.lang.c Subject: Re: ANSI C Standard: Float/Double Handling Message-ID: <4612@utzoo.UUCP> Date: Sat, 10-Nov-84 19:42:17 EST Article-I.D.: utzoo.4612 Posted: Sat Nov 10 19:42:17 1984 Date-Received: Sat, 10-Nov-84 19:42:17 EST References: <1152@orca.UUCP> Organization: U of Toronto Zoology Lines: 31 > The standard math library was also modified to include both > float and double versions of each function, e.g. float sin() and > double dsin(), float exp() and double dexp() etc. It took about > a week to do everything. > ... > It seems to be a poor idea to make all float constants > double, because a single constant in an expresion will promote > all the way through the expression, causing all those unwanted > conversions. > > Anyone considering this type of thing should beware of side > effects, e.g printf will treat a float argument as double ... Your approach can be summed up as "if you want double, you must say so". The problem with this approach is that it breaks a large percentage of the existing floating-point programs. Avoiding breakage of existing valid programs is a major item in the ANSI C committee's charter. This unfortunately means that places where things default to double right now must generally stay that way. Changing the types accepted by (e.g.) sin(), changing the type of "1.23e5", and changing the type behavior at the function-call interface are all changes capable of causing massive breakage and unportability. There is also the view that people who use floating point casually should get the most accurate version, i.e. double. If somebody is seriously concerned about space or speed, then *he* should pay the price of having to ask for float explicitly. I concede that some of the techniques one must use to ask for it are a bit clumsy. -- Henry Spencer @ U of Toronto Zoology {allegra,ihnp4,linus,decvax}!utzoo!henry