Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!decwrl!shelby!neon!carcoar!wilson From: wilson@carcoar.Stanford.EDU (Paul Wilson) Newsgroups: comp.arch Subject: floating point formats -- usage of small floats Summary: can I sacrifice a few bits of range w/o annoying most programs? Keywords: floating point formats, floating point usage, Lisp, heaps Message-ID: <1990Mar5.031003.12107@Neon.Stanford.EDU> Date: 5 Mar 90 03:10:03 GMT References: <3880@uceng.UC.EDU> Sender: root@Neon.Stanford.EDU (System PRIVILEGED Account) Reply-To: wilson@carcoar.Stanford.EDU (Paul Wilson) Organization: U. of Illinois at Chicago (UIC, *not* UofC or UIUC) Lines: 54 I'm looking for info that would be useful in implementing short floating point numbers for Lisp/Smalltalk/etc. The basic idea is that I want short (1-word) floating point numbers to fit in one 32-bit words, *with* a runtime tag included. My plan is to store the number shifted left a few bits, at a tag in the lower bits. Having the number fit in a word is a big advantage, especially if you've got a generational garbage collector. (They have to be careful about pointer creation, in ways that can needlessly slow down programs that allocate a lot of floats.) Of course, this means I have to sacrifice a few bits of a standard 32-bit float to make it fit. I figure that I can just lop a couple of bits of of the exponent part, and leave the fraction part alone. That way, I sacrifice range of floats but not precision. If a float result goes out of that range, I'll make a full-sized floating point object on the heap, and use a tagged pointer to it. This is analogous to the "fixnum" (immediate short int) / "bignum" (long, heap-allocated) strategy used for integers. Now the question: How far can I carry this? Can I take five bits out of the exponent and still express most numbers most people would use? (How many bits do IEEE 32-bit floats use for the expt in the first place?) If not 5, can I do 4, 3, or 2? Has anybody done any studies of the distribution of floating point values for real programs? My guess is that most programs don't generate *any* floating point values outside of a fairly narrow range, so that most programs would not require *any* big floats. (I'm not looking for Lisp program data here -- I wouldn't want to assume that people only want to run the kinds of programs traditionally written in Lisp. C and Fortran data would be fine.) And if I've made any stupid assumptions, such that this is a bad idea anyway, please gently clue me in. (I know close to nothing about computer arithmetic.) Thanks, Paul Paul R. Wilson Software Systems Laboratory lab ph.: (312) 996-9216 U. of Illin. at C. EECS Dept. (M/C 154) wilson@bert.eecs.uic.edu Box 4348 Chicago,IL 60680 Paul R. Wilson Software Systems Laboratory lab ph.: (312) 996-9216 U. of Illin. at C. EECS Dept. (M/C 154) wilson@bert.eecs.uic.edu Box 4348 Chicago,IL 60680