Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Forth > Re: Writing flo...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 12 of 12 Topic 3956 of 4287
Post > Topic >>

Re: Writing floating point values to file

by Larry Webber <thecoots@[EMAIL PROTECTED] > Mar 23, 2008 at 11:48 PM

On Sun, 23 Mar 2008 09:23:24 -0700, Ian Osgood wrote:

> On Mar 22, 9:08 pm, 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.
> 
> From 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
> 
> From 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

Ian,

My reply from earlier this evening seemed to have dropped in the bit 
bucket so forgive me if two posts show up.

Your assumption about the plotting/math program is correct and I failed 
to state this clearly in my earlier post. The plotting/math program 
expects the data to be ASCII.

Following the information you (and I believe Bruce McFarling in a 
different post) provided me, I wrote some words including REPRESENT and 
this does 99% of what is needed. These worked on both vfxlin and gforth, 
which are the two implementations we are working with currently. 

The only remaining task is to insert a decimal point into the character 
field at the appropriate place. The information for this location is 
returned on the stack after invoking REPRESENT.

To be honest my friend and I were not aware of REPRESENT and we are both 
somewhat rusty with Forth (and rooted back in the F-83 days). I think we 
need to brush up on the ANSI words a bit. (:=)>

Thanks Ian - and to all who responded to my request for help.

Larry Webber
 




 12 Posts in Topic:
Writing floating point values to file
Larry Webber <thecoots  2008-03-22 23:57:53 
Re: Writing floating point values to file
Bruce McFarling <agila  2008-03-22 19:28:34 
Re: Writing floating point values to file
Bruce McFarling <agila  2008-03-22 21:32:34 
Re: Writing floating point values to file
Bruce McFarling <agila  2008-03-23 07:04:56 
Re: Writing floating point values to file
Ian Osgood <iano@[EMAI  2008-03-23 09:23:24 
Re: Writing floating point values to file
Bruce McFarling <agila  2008-03-23 13:25:36 
Re: Writing floating point values to file
Larry Webber <thecoots  2008-03-23 04:08:07 
Re: Writing floating point values to file
mhx@[EMAIL PROTECTED] (M  2008-03-23 06:50:50 
Re: Writing floating point values to file
Albert van der Horst <  2008-03-23 11:26:22 
Re: Writing floating point values to file
anton@[EMAIL PROTECTED]   2008-03-23 13:34:46 
Re: Writing floating point values to file
anton@[EMAIL PROTECTED]   2008-03-23 13:24:26 
Re: Writing floating point values to file
Larry Webber <thecoots  2008-03-23 23:48:16 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 13 3:17:33 CDT 2008.