Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #1629
| From | mhx@iae.nl (Marcel Hendrix) |
|---|---|
| Subject | Re: Printing a floating point number |
| Newsgroups | comp.lang.forth |
| Message-ID | <58951407998436@frunobulax.edu> (permalink) |
| Date | 2011-04-28 21:08 +0200 |
| References | <4db92fad.24509129@192.168.0.50> |
| Organization | chello.nl |
stephenXXX@mpeforth.com (Stephen Pelc) writes Re: Printing a floating point number
> On Thu, 28 Apr 2011 00:49:44 -0600, jsgraham <jsgrahamus@yahoo.com> wrote:
>>Is there a way to print a float in a base other 10?
> No.
FORTH> needs hexfloat
Creating --- Hexfloat Version 2.01 ---
Convert among IEEE 754 32-bit, 64-bit or 80-bit float,
C99 mixed hex/decimal string, and raw hex string formats.
User words:
xf>hex$ df>hex$ sf>hex$ -- ( F: r -- ) ( -- c-addr u )
hex$>xf hex$>df hex$>sf -- ( c-addr u -- ) ( F: -- r )
xf>mix$ df>mix$ sf>mix$ -- ( F: r -- ) ( -- c-addr u )
mix$>xf mix$>df mix$>sf -- ( c-addr u -- ) ( F: -- r )
Remark: The number of digit groups for hex$ is fixed -- groups
shall have 4 hex digits. Overflow is possible: more
than 8, 16, or 20 digits for sf, df, xf respectively.
Remark: For mix$, sign and integer bit are optional, but `.'
and `p' are mandatory. Contrary to hex$ the number
of groups is free, but the total number of digits
of the mantissa should fit in the target float.
ok
FORTH> pi xf>hex$ TYPE 4000 C90F DAA2 2168 C235 ok
FORTH> pi xf>mix$ TYPE +1.921F B544 42D1 846A p+1 ok
FORTH> 3.14e0 xf>mix$ TYPE +1.91EB 851E B851 EB84 p+1 ok
FORTH> s" +1.91EB 851E B851 EB84 p+1" mix$>xf f. 3.140000 ok
Nothing is impossible in Forth.
-marcel
Back to comp.lang.forth | Previous | Next — Previous in thread | Find similar | Unroll thread
Printing a floating point number jsgraham <jsgrahamus@yahoo.com> - 2011-04-27 13:09 -0600
Re: Printing a floating point number mhx@iae.nl (Marcel Hendrix) - 2011-04-27 22:03 +0200
Re: Printing a floating point number stephenXXX@mpeforth.com (Stephen Pelc) - 2011-04-27 20:52 +0000
Re: Printing a floating point number jsgraham <jsgrahamus@yahoo.com> - 2011-04-27 15:47 -0600
Re: Printing a floating point number jsgraham <jsgrahamus@yahoo.com> - 2011-04-28 00:49 -0600
Re: Printing a floating point number stephenXXX@mpeforth.com (Stephen Pelc) - 2011-04-28 09:13 +0000
Re: Printing a floating point number mhx@iae.nl (Marcel Hendrix) - 2011-04-28 21:08 +0200
csiph-web