set precision for a floating number 
Author Message
 set precision for a floating number

How can I set up the precision for a floating number with the format-out? I
want to print out a floating number with one fixed decimal number.

Cheers,

Joe



Sat, 26 Oct 2002 03:00:00 GMT  
 set precision for a floating number

Quote:

> How can I set up the precision for a floating number with the format-out? I
> want to print out a floating number with one fixed decimal number.

I don't think we have that yet.

The format library contains format-to-string, which you could use and then
do text-processing to get the string how you want it (chop or round or
whatever).

-- Bruce



Sat, 26 Oct 2002 03:00:00 GMT  
 set precision for a floating number

Quote:

> How can I set up the precision for a floating number with the
> format-out? I want to print out a floating number with one fixed
> decimal number.

Functional Developer and Gwydion Dylan both do not support setting
precision of floating point numbers with format-out as far as I
know. I don't think it is included in the DRM either.

David Lichteblau's xformat library[1] (a Dylan implementation of the
Common Lisp FORMAT) does allow formatting of floats. You might like to
take a look at that. However, in the notes for that library it
contains the following caveat:

  "CMU CL's floating-point directives are based on FLONUM-TO-STRING
   and SCALE-EXPONENT.  Both are missing in gd currently.  A set of
   workarounds can be found in `flonum-fakes.dylan', but the functions
   there are based on a broken algorithm.  Let me repeat that: FLONUM
   PRINTING IS BROKEN!

   The directives as such are implemented fully, though.  If you want
   to play around with them, keep in mind that you can't expect
   accuracy, but that all basic functionality should be there."

[1] ftp://berlin.ccc.de/pub/gd/contributions/xformat-0.3.tar.gz

Chris.
--
http://www.double.co.nz/dylan



Sat, 26 Oct 2002 03:00:00 GMT  
 set precision for a floating number

Quote:

> How can I set up the precision for a floating number with the format-out? I
> want to print out a floating number with one fixed decimal number.

In Functional Developer 2.0 you can use the following:

? float-to-string(3.141592, decimal-points: 1);
  $1 = "3.1"

float-to-string is in the functional-extensions library/module.



Sat, 26 Oct 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Precision of Floating Point Numbers (Was: Second historic...)

2. Order of float and float precision contaigon defined?

3. Getting a floating point number from a float-object

4. 10 byte float numbers from ST 8 byte numbers

5. auto-numbered key - how to set the starting number

6. sub on a float loses precision

7. Convert to single precision float

8. float precision

9. double precision floating point arithmetic

10. Precision of Floating Point Types

11. Precision for float in Modelsim?

12. Float & precision

 

 
Powered by phpBB® Forum Software