develooper Front page | perl.perl6.language | Postings from October 2001

RE: NaN semantics

Thread Previous | Thread Next
From:
David Whipp
Date:
October 10, 2001 13:15
Subject:
RE: NaN semantics
Message ID:
000001c151c8$3adf8240$926464c4@intranet.fastchip.com
> > > First this thread tells me that "123foo" will be 123 in numeric
> > > context. Now I find myself wondering what "123indigo" evaluates
> > > to!
> >
> > It would evaluate to 123.  If "use complex" is in effect, it would
> > evaluate to 123i.  At least that's the position I'm taking at the
> > moment  ;-)
> 
> 123i unless of course we use nano prefix (postfix?), then it would be
> 0.000000123i of course. ;)

In which case "123foo" is 123e-15 (femto).

If we are going to have all these postfixes, then we would probably
want invalid ones to evaluate to NaN instead of truncating them.
We can always have a standard fn/method that strips the invalid
characters off the end if the string:


  my $string = "1.23Ki4b2XXX".
  my $a = +string; # NaN
  my $b = +$string.numeric_prefix; # 1230 + 16i
  my $c = +$string.real_prefix;    # 1230
  my $d = +$string.integer_prefix; # 1

or some such thing.


Dave.


Thread Previous | Thread Next


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