Talk About Network



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: f. to strin...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 17 Topic 3979 of 4053
Post > Topic >>

Re: f. to string?

by Bruce McFarling <agila61@[EMAIL PROTECTED] > Mar 29, 2008 at 09:22 AM

On Mar 29, 9:22 am, Frank Buss <f...@[EMAIL PROTECTED]
> wrote:

> REPRESENT looks a bit like I could use it, but it is more complicated. I
> just need a function where I can specify the number of digits after the
> decimal point, e.g. like the C function sprintf(buf, "%.3f", number). I
> need it for FICL, so I could implement it myself in C, but would be nice
to
> use Forth for it. Additional problem: FICL doesn't have REPRESENT.

If FICL is a C-based forth, it should be straightforward to add
REPRESENT. sprintf itself would be the core function, after stripping
out the sign of the significand for the flag.

This is the second time this has come up this month ... what would you
want as the stack comment for a useful simple buffered floating point
output. A pedantic one would be:

>f$ ( addr u1 u2 u3 c flag -- flag=error? )

addr ... address of buffer, with at least u1+u2+4 chars.
u1 ... digits of significand
u2 ... decimal place, counting from ".significand" as 0
u3 ... digits of exponent
c ... exponent indicator character
flag ... display leading sign if positive

I'm thinking that order is right to make wrappers for normal
defaults ... say

: >scientific-f$ ( addr u1 ) 1 3 [CHAR] E FALSE >f$ ;




 17 Posts in Topic:
f. to string?
Frank Buss <fb@[EMAIL   2008-03-29 14:22:05 
Re: f. to string?
Helmar <helmwo@[EMAIL   2008-03-29 06:26:31 
Re: f. to string?
Bruce McFarling <agila  2008-03-29 09:22:10 
Re: f. to string?
anton@[EMAIL PROTECTED]   2008-03-29 20:15:50 
Re: f. to string?
Bruce McFarling <agila  2008-03-29 17:00:03 
Re: f. to string?
"Ed" <nospam  2008-03-30 15:11:45 
Re: f. to string?
anton@[EMAIL PROTECTED]   2008-03-30 19:01:29 
Re: f. to string?
Bruce McFarling <agila  2008-03-29 22:50:53 
Re: f. to string?
Bruce McFarling <agila  2008-03-30 15:30:42 
Re: f. to string?
"Ed" <nospam  2008-03-30 15:02:22 
Re: f. to string?
Bruce McFarling <agila  2008-03-29 22:19:43 
Re: f. to string?
"Ed" <nospam  2008-03-31 11:02:54 
Re: f. to string?
Bruce McFarling <agila  2008-03-30 17:49:38 
Re: f. to string?
"Ed" <nospam  2008-04-01 14:00:42 
Re: f. to string?
Bruce McFarling <agila  2008-03-31 20:38:09 
Re: f. to string?
"Ed" <nospam  2008-04-04 17:53:28 
Re: f. to string?
Bruce McFarling <agila  2008-04-04 11:10:00 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Fri May 16 8:54:21 CDT 2008.