Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rochester!cornell!uw-beaver!tektronix!cae780!daniels From: daniels@cae780.TEK.COM (Scott Daniels) Newsgroups: comp.lang.c Subject: Re: Types Message-ID: <4150@cae780.TEK.COM> Date: Fri, 26-Jun-87 12:52:15 EDT Article-I.D.: cae780.4150 Posted: Fri Jun 26 12:52:15 1987 Date-Received: Sat, 27-Jun-87 11:51:04 EDT References: <7264@brl-adm.ARPA> <734@sdchema.sdchem.UUCP> <293@osupyr.UUCP> <541@l.cc.purdue.edu> <820@mcgill-vision.UUCP> Reply-To: daniels@cae780.UUCP (Scott Daniels) Organization: Tektronix, Inc., Beaverton, OR. Lines: 42 In article <820@mcgill-vision.UUCP> mouse@mcgill-vision.UUCP (der Mouse) writes: >In article <541@l.cc.purdue.edu>, cik@l.cc.purdue.edu (Herman Rubin) writes: >>>> 4. Allow floating point numbers to be given in hex. Try putting >>>> in 2^-32 as a floating point or double constant. Why should one >>>> have to risk computer roundoff when it is totally unnecessary? >>> Some people have noted that this might be a niece feature, I forget >>> what if any problems there are with this. >> There are no problems with this, but I do not know of any notation >> that has been suggested to do this. > >There is a problem with both of those: suppose floating-point is not >stored in a binary format - say it uses floating-point ternary? >Suppose the machine uses packed decimal? Suppose you figure out your >hex constant for your VAX and then have to port to your Sun? Then to >your 80x86? Then to your IBM mainframe? Then to that packed decimal >machine I mentioned? Yech. Just write 1/65536.0/65536.0 and let the >compiler figure it out. > The problem being pointed out is that there are no binary formats provided. We have done quite well with providing decimal formats where the underlying machine has no decimal floating point, why not have a similar notation for binary (or base N if you can agree on a nice notation). Given such a format, it is possible to produce a terse binary text string which represented the exact value that your machine calculated, but would be readable on another machine with the closest approximation of which that machine is capable. The kind of notation desired is like: 0.5 == 0x0.8, 0.625 == 0x0.A, 128.5 == 0x80.8, 128.5 == 0x8.08@4 Hard to resolve issues are things like: base of expression of exponent, is the exponent a power of two or the base (should the last be 0x8.08@1), How do you represent Nans (or do you). It certainly seems to me that such a notation is greatly to be desired (we can agree that the floating point on most machines is closer to binary than decimal). What we do not have is enough practical experience with a notation to be sure we know a solution. That is why Ansi-C should not have such a format. FROM: Scott Daniels, Tektronix CAE 5302 Betsy Ross Drive, Santa Clara, CA 95054 UUCP: tektronix!teklds!cae780!daniels {ihnp4, decvax!decwrl}!amdcad!cae780!daniels {nsc, hplabs, resonex, qubix, leadsv}!cae780!daniels