MOO-cows Mailing List Archive
[Prev][Next][Index][Thread]
Re: [SERVER] Interesting error on make with FUP (1.8) & 1.8.0b3
Followup to: <9603070924.aa20294@forney.scinc.com>
By author: ThwartedEfforts <abakun@scinc.com>
In newsgroup: local.moo
> >
> >files.c: In function `bf_filewrite':
> >files.c:367: warning: double format, pointer arg (arg 3)
> >files.c: In function `bf_fileappend':
> >files.c:492: warning: double format, pointer arg (arg 3)
> > DUH!, TYPE_FLOAT is a pointer to a float, in order to make up for the fact
> >that different systems have different size floats (I assume).
> > I changed the above lines to dereference the pointer to get to the REAL
> >value, instead of interpreting the pointer as a float, as the above line
> >does. Seems weird that this is the case, since this, seemingly, would make
> >the binary more portable, which is of dubious utility. Who knows. I'm not
> >questioning the implementation of memory storage/handling in the server.
> >
It has to do with the fact that on most systems, doubles are 8 bytes
and ints are 4. On such systems, a type cell is 8 bytes, but would
increase to 12 or 16 (because of alignment) if a double was included.
This would cause *all* values to increase in size, causing massive
memory bloat. I implemented it through pointers, because I assumed
that the relatively massive memory cost of using dynamically-allocated
floats would be more than offset by th assumed facts that float values
are fairly rare. If your db has fewer than 1 float value out of every
100, this is definitely the preferred method.
> >
> >But should look like this:
> >
> > case TYPE_FLOAT:
> >---> fprintf (outFile, "%g\n", *(arglist.v.list[3].v.list[i].v.fnum));
> > break;
%g isn't the best either, as it only preserves 6 digits of precision.
Use something like:
fprintf(outFile, "%*g\n", DBL_DIG+4, *(arglist.v.list[3].v.list[i].v.fnum));
Remove the +4 if the output value is intended for human consumption,
rather than to be read back into a computer.
-hpa
--
PGP public key available - finger hpa@zytor.com
"The earth is but one country, and mankind its citizens." -- Bahá'u'lláh
GE/CS 3.1 d- s-:- a- C++++ ULIS++++$ P+++ L++++>+++++ E++ W++ N++ o+ K
w--- O@ M V- PGP+ t+ 5++ X? R@ tv- b++ DI++++ D++(+) G e++ h- r-- y-
References:
Home |
Subject Index |
Thread Index