On Mar 22, 9:08=A0pm, Larry Webber <theco...@[EMAIL PROTECTED]
> wrote:
> On Sat, 22 Mar 2008 19:28:34 -0700, Bruce McFarling wrote:
> > On Mar 22, 7:57 pm, Larry Webber <theco...@[EMAIL PROTECTED]
> wrote:
> >> I am using both gforth and an alpha release of vfxlin forth. What is
> >> the recommended way of writing floating point values to a file? For
> >> writing integer values there are the "pictured number conversion"
> >> words. What is the recommended ****table way to do this with gforth
and
> >> vfxlin?
>
> > Not because I know the answer, but because I'm interested in hearing
it:=
>
> > (1) Are you asking about writing a text string representing the
floating=
> > point value for later display?
>
> > (2) Or are you asking about writing a floating point value in binary
> > form for later retrieval and computation?
>
> Bruce,
>
> The latter. The need is to write floating point values to a file. The
> data will later be read by a mathematical program which will both plot
> the values and perform certain numerical analysis on the data.
>
> A friend was able to "get under the hood" of gforth and figure out how
to
> vector the output to a file but we would like a more straight forward
> method which is implementation neutral. I don't see a straightforward
way
> of doing this presently.
>
> Thanks,
>
> Larry
So now you need to tell us the format in which your math program
expects floating point numbers.
=46rom your comment about revectoring, I'm assuming you require a text
representation instead of binary IEEE, and you were trying to revector
F. or one of its variations. Look to the implementation of these words
(SEE F. SEE FE.) for non-****table factors for getting string
representations (GNU Forth: F$ SCRATCH). The only ****table word for
getting decimal text from a FLOAT is REPRESENT ( addr len -- exponent
sign? valid? ) ( F: f -- ).
http://www.forthfreak.net/dpans/dpans12.htm#12.6.1.2143
=46rom REPRESENT it is relatively straightforward to get an exponential
form (-0.DDDeNNN) suitable for re-parsing. Much of the complexity of
the implementation of F. is dealing with pretty-printing issues like
non-exponential forms, leading and trailing zeros, and limiting
precision.
This brings up a question: is there a standard for textual
representation of floating point numbers? I only know of the defacto
standard set by the C standard library's execrable printf/scanf("%f").
Ian


|