Improving Dylan floating-point support 
Author Message
 Improving Dylan floating-point support

[repost]

There are several features missing from Dylan's support for
floating-point arithmetic that I would consider essential for any sort
of numeric programming.  I propose adding the following symbols to the
common-extensions module of common-dylan:

  // Numerics
  function decode-float (<float>) => (<float>, <integer>, <float>);
  function scale-float (<float>, <integer>) => (<float>);
  function float-radix (<float>) => (<integer>);
  function float-digits (<float>) => (<integer>);
  function float-precision (<float>) => (<integer>);

  constant $single-float-epsilon :: <single-float>;
  constant $double-float-epsilon :: <double-float>;
  constant $extended-float-epsilon :: <extended-float>;

  constant $minimum-single-float-exponent :: <integer>;
  constant $maximum-single-float-exponent :: <integer>;
  constant $minimum-double-float-exponent :: <integer>;
  constant $maximum-double-float-exponent :: <integer>;
  constant $minimum-extended-float-exponent :: <integer>;
  constant $maximum-extended-float-exponent :: <integer>;

  function finite? (<object>) => (<boolean>);
  function infinite? (<object>) => (<boolean>);

  // Formatting
  function string-to-float
      (<string>, #"key", #"start", #"end", #"default-class")
   => (<float>, <integer>);

The semantics of these follows that of the corresponding functions in
the ANSI Common Lisp standard
( http://www.*-*-*.com/ ).

Additional constants such as $most-positive-single-float and the like
( http://www.*-*-*.com/ ) were
omitted but could be added.

Support for NaN (Not a Number) was also omitted.

I plan on implementing these in Gwydion Dylan in the next few days.
Any comments or suggested additions would be appreciated.

-Peter-



Wed, 02 Nov 2005 00:35:17 GMT  
 Improving Dylan floating-point support



Quote:

> [repost]

> There are several features missing from Dylan's support for
> floating-point arithmetic that I would consider essential for any sort
> of numeric programming.  I propose adding the following symbols to the
> common-extensions module of common-dylan:

>   // Numerics
>   function decode-float (<float>) => (<float>, <integer>, <float>);
>   function scale-float (<float>, <integer>) => (<float>);
>   function float-radix (<float>) => (<integer>);
>   function float-digits (<float>) => (<integer>);
>   function float-precision (<float>) => (<integer>);

>   constant $single-float-epsilon :: <single-float>;
>   constant $double-float-epsilon :: <double-float>;
>   constant $extended-float-epsilon :: <extended-float>;

>   constant $minimum-single-float-exponent :: <integer>;
>   constant $maximum-single-float-exponent :: <integer>;
>   constant $minimum-double-float-exponent :: <integer>;
>   constant $maximum-double-float-exponent :: <integer>;
>   constant $minimum-extended-float-exponent :: <integer>;
>   constant $maximum-extended-float-exponent :: <integer>;

>   function finite? (<object>) => (<boolean>);
>   function infinite? (<object>) => (<boolean>);

>   // Formatting
>   function string-to-float
>       (<string>, #"key", #"start", #"end", #"default-class")
>    => (<float>, <integer>);

> The semantics of these follows that of the corresponding functions in
> the ANSI Common Lisp standard
> (http://www.lispworks.com/reference/HyperSpec/Body/f_dec_fl.htm).

> Additional constants such as $most-positive-single-float and the like
> (http://www.lispworks.com/reference/HyperSpec/Body/v_most_1.htm) were
> omitted but could be added.

> Support for NaN (Not a Number) was also omitted.

> I plan on implementing these in Gwydion Dylan in the next few days.
> Any comments or suggested additions would be appreciated.

These all sound fine to me.

A serious blunder made in Dylan was the definition of only
\= and \< as generics, but not \>.  In "real" math, these inequalities
form a trichotomy.  In IEEE, they do not.  NaNs (and maybe
infinities) require that all three be explicitly defined, since
"not >" does not imply either "=" or ">".



Thu, 03 Nov 2005 23:03:44 GMT  
 Improving Dylan floating-point support

Quote:
> I plan on implementing these in Gwydion Dylan in the next few days.
> Any comments or suggested additions would be appreciated.

William Kahan (http://www.cs.berkeley.edu/~wkahan/) has had a lot to
say on the topic off floating point and programming languages.  Maybe
some of his ideas apply to dylan?


Fri, 04 Nov 2005 05:00:39 GMT  
 Improving Dylan floating-point support

Quote:

> > I plan on implementing these in Gwydion Dylan in the next few days.
> > Any comments or suggested additions would be appreciated.

> William Kahan (http://www.cs.berkeley.edu/~wkahan/) has had a lot to
> say on the topic off floating point and programming languages.  Maybe
> some of his ideas apply to dylan?

Of course Kahan has a lot of things to say that might apply, and his
presentation is always... interesting.  Some references that might be
contain some easier-to-apply advice include:

* Goldberg, David.  What Every Computer Scientist Should Know About
  Floating-Point Arithmetic.  ACM Computing Surveys 23, 1 (March 1991).
* Goldberg, David.  The Design of Floating-Point Data Types.  ACM Letters
  on Programming Languages and Systems 1, 2 (June 1992).
* Hauser, John.  Handling Floating-Point Exceptions in Numeric
  Programs.  ACM Transactions on Programming Languages and Systems 18, 2
  (March 1996).
* ISO/IEC 10697:1994(E).  Information Technology--Language Independent
  Arithmetic--Part 1: Integer and Floating-Point Arithmetic.
* ISO/IEC 10967-2:2001. Information Technology--Language Independent
  Arithmetic--Part 2: Elementary Numerical Functions.

The standards are somewhat expensive, but committee draft versions are
available on the working group's web site,
http://std.dkuug.dk/JTC1/SC22/WG11/.

-Peter-



Sat, 05 Nov 2005 11:30:07 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. An alternative to floating point (was Re: Floating point non-exactness)

2. IBM 370 Floating point to IEEE floating point

3. Dylan floating-point numbers

4. floating point support

5. fixed point vs floating point

6. code with fixed-point or floating-point

7. fixed point vs floating point

8. fixed point vs floating point

9. Floating Point vs Fixed Point

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

11. vax floating pont to unix floating point

12. Wing IDE 1.1.6 adds much improved Zope support

 

 
Powered by phpBB® Forum Software