Path: utzoo!utgpu!watserv1!watmath!att!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!leah!bingvaxu!vu0310 From: vu0310@bingvaxu.cc.binghamton.edu (R. Kym Horsell) Newsgroups: comp.arch Subject: Re: F.P. vs. arbitrary-precision Message-ID: <3969@bingvaxu.cc.binghamton.edu> Date: 9 Sep 90 19:27:13 GMT References: <3755@osc.COM> <4513@taux01.nsc.com> <119244@linus.mitre.org> <6837.26e7ee92@vax1.tcd.ie> <389@tygra.UUCP> Reply-To: vu0310@bingvaxu.cc.binghamton.edu.cc.binghamton.edu (R. Kym Horsell) Organization: SUNY Binghamton, NY Lines: 49 In article <389@tygra.UUCP> dave@tygra.UUCP (David Conrad) writes: \\\ >*My* C doesn't have and int * int = int. I know because the CPU doesn't >support it. What it does is int * int = long, and then it casts the >long back into an int if it'll fit. \\\ This is a rather strange idea; the last time I heard of a crock whereby the type of an expression can't be determined until runtime (which is what you imply, see below) was raising an integer to integral power in Algol -- if the exponent is <0 you get a real else you get an integer. As I recall Burroughs kludged this by representing integers and reals in a common format (not _too_ unusual, see the '87 chips) but they had the binary point ON THE RIGHT. The problem with int->int->long for (any?) of the common arithmetic ops is expressions like the following (this is typical of C, but other exprs can be fudged up in most of the modern langs): int x,y,z; ... x = (x==y ? x*x : y); (We can also produce all sorts of similar arguments based on the associativety and commutativity of *). Now, since we have an x*x inside the conditional, and for the sake of argument let's say the optimizer doesn't play with this code too much (or else I'll think up a reall _big_ example where it won't) then how do we deal with the type indeterminacy as you (and previous posts) have described it? Do we hang a bit of code near the x*x and _decide_ that we have a long and cast it to an int or do we simply _always_ cast x*x to an int? If the latter then we _really_ have implemented int x int->int. There are _some_ situations where this int x int -> long may be useful, e.g. long x; int y,z; x = y*z; We really get the entire product! Perhaps your compiler kicks in in only this (or similar) case? I _still_ don't like it; it isn't portable (there's a C standard for one thing). -Kym Horsell ===