[m-dev.] Re: pragma fact_table
Fergus Henderson
fjh at cs.mu.oz.au
Thu Feb 27 16:55:06 AEDT 1997
David Matthew OVERTON, you wrote:
>
> > !BOXED_FLOAT implies sizeof(Float) <= sizeof(Integer),
> > but BOXED_FLOAT does not imply sizeof(Float) > sizeof(Integer).
>
> Well the comment in runtime/conf.h should be changed then. This is
> what it says:
>
> ** BOXED_FLOAT double precision floats do not fit in a Word,
> ** and must be boxed.
runtime/conf.h.in:
Clarify the documentation for BOXED_FLOAT: it does not imply
that sizeof(Float) <= sizeof(Integer).
diff -u -r1.12 conf.h.in
--- conf.h.in 1997/02/12 07:45:51 1.12
+++ conf.h.in 1997/02/27 05:43:28
@@ -22,8 +22,12 @@
**
** WORD_TYPE the base type for the definition of Word.
** LOW_TAG_BITS the number of low-order tag bits we can use.
-** BOXED_FLOAT double precision floats do not fit in a Word,
-** and must be boxed.
+** BOXED_FLOAT true if double precision floats might not fit
+** in a Word, and hence must be boxed.
+** (Note that when bootstrapping from the source
+** distribution, we initially build things without
+** BOXED_FLOAT even on machines for which
+** sizeof(Float) <= sizeof(Integer).)
** HAVE_SYSCONF the machine has the sysconf() syscall.
** HAVE_GETPAGESIZE the machine has the getpagesize() syscall.
** HAVE_MEMALIGN the machine has the memalign() function.
> How can I check that sizeof(Float) > sizeof(Integer) at compile time,
> since sizeof() does not work with the #if preprocessor command? If
> this means adding a new parameter to the configure script I've got no
> idea how to do this.
It would mean adding a new parameter to the configure script.
But you don't need to check it. Just write code that works
regardless of the relative sizes. In fact your code below does that.
> > > union FloatInteger {
> > > Float f;
> > > Integer i[sizeof(Float)/sizeof(Integer)];
> > > };
> > >
> > > Integer
> > > hash_float(Float f)
> > > {
> > > union FloatInteger fi;
> > > size_t i;
> > > Integer h = 0;
> > >
> > > fi.f = f;
> > >
> > > for (i = 0; i < sizeof(Float)/sizeof(Integer); i++)
> > > h ^= fi.i[i];
> >
> > This code won't work if sizeof(Float) is not an even multiple of
> > sizeof(Integer).
>
> I can't see why it wouldn't work. It will compute a hash value, it
> just won't use all the bits of the float.
Oh, my apologies, you're right. I thought it would use too many bits.
That code is OK.
However, it might be better to use
if (sizeof(Float) % sizeof(Integer) == 0) {
... your code above ...
} else {
... code using array of chars ...
}
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list