develooper Front page | perl.perl6.language.data | Postings from August 2000

38 (v2): Standardise Handling Of Abnormal Numbers Like InfinitiesAnd NaNs

From:
Casey R. Tweten
Date:
August 24, 2000 09:49
Subject:
38 (v2): Standardise Handling Of Abnormal Numbers Like InfinitiesAnd NaNs
Message ID:
Pine.OSF.4.21.0008241240260.24565-100000@home.kiski.net
=head1 TITLE

Standardise Handling Of Abnormal Numbers Like Infinities And NaNs

=head1 VERSION

  Maintainer: Jarkko Hietaniemi <jhi@iki.fi>
  Date: 05 Aug 2000
  Version: 2
  Mailing List: perl6-internals@perl.org
  Number: 38

=head1 ABSTRACT

The handling of various abnormal numeric entities like infinities
(positive, negative), not-a-numbers (NaNs, various kinds of those,
signaling, non-signaling), epsilons (positive and negative) is left to
the native math libraries.  A more concerted effort to standardise the
behaviour of Perl across platforms would be desirable.

=head1 DESCRIPTION

The abstract pretty much took care of it.

=head1 IMPLEMENTATION

In an SV have bits that mark whether the numeric aspect of the scalar
is abnormal and if so, what kind of abnormality are we dealing with.
The Perl math operations have to watch out for those bits and do The
Right Thing before the native math ops kick in, so that for example
infinity + anything-but-nan = infinity, anything + nan = nan, and so on.

Watching out for the abnormality bits may be a performance hit.  If
so, it may be possible during the configuration phase probe how well
the native math semantics obey the semantics we define for Perl, and
let the native math take care of where it and us agree.

mjd quoth:

        If Perl supported bignums as a native scalar type, then
        handling of nans and infinities would come out of that naturally.

        Supporting bignums in Perl would insulate users from details
        of integer and float size on native platforms and would
        improve portability of Perl programs.

        Programs would be more robust.  Instead of failing
        mysteriously when a number overflowed, they would continue to
        work properly.
        
        Prior art:  Lisp.

=head1 REFERENCES

        Math::Complex
        PDL::Math [suggested by Tim Jenness]
        p6rfc for bigints [to be written]

-- 
print(join(' ', qw(Casey R. Tweten)));my $sig={mail=>'crt@kiski.net',site=>
'http://home.kiski.net/~crt'};print "\n",'.'x(length($sig->{site})+6),"\n";
print map{$_.': '.$sig->{$_}."\n"}sort{$sig->{$a}cmp$sig->{$b}}keys%{$sig};
my $VERSION = '0.01'; #'patched' by Jerrad Pierce <belg4mit at MIT dot EDU>




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About