toExternalString for nonreal RR objects
The following behavior of toExternalString isn't quite right:
i1 : x = numeric infinity
o1 = infinity
o1 : RR (of precision 53)
i2 : toExternalString oo
o2 = infinity
i3 : value oo
o3 = infinity
o3 : InfiniteNumber
i4 : x = numeric indeterminate
o4 = NotANumber
o4 : RR (of precision 53)
i5 : toExternalString oo
o5 = NotANumber
i6 : value oo
o6 = NotANumber
o6 : Symbol
Ideally, value @@ toExternalString should act like identity, and in both cases, we're ending up with instances of a completely different class!
To solve this, we:
- Introduce
NotANumber, a new instance ofIndeterminateNumber. - Introduce the
Number_ZZsyntactic sugar fornumeric. - Modify
toExternalStringto take advantage of these changes.
So now we have:
i1 : toExternalString numeric infinity
o1 = infinity_53
i2 : value oo
o2 = infinity
o2 : RR (of precision 53)
i3 : toExternalString numeric indeterminate
o3 = NotANumber_53
i4 : value oo
o4 = NotANumber
o4 : RR (of precision 53)
This is a draft for now since there are conflicts with #3630 and I should add tests and docs.
I scrapped the Number_ZZ synonym for numeric and changed this to just use numeric(...) in the output of toExternalString for these cases. Also NotANumber is now just a synonym for indeterminate rather than a distinct object.
I also noticed that we weren't consistent for how we dealt with these things in CC. If the real or imaginary part was infinity or nan, we did all sorts of different things:
i1 : toExternalString toCC numeric infinity
o1 = toCC(infinity,.0p53)
i2 : toExternalString toCC(numeric infinity, 5.0)
o2 = toCC(infinity,infinity)
i3 : toExternalString toCC(53, numeric infinity, 5)
o3 = toCC(infinity,.5p53e1)
i4 : toExternalString toCC numeric indeterminate
o4 = toCC(NotANumber,.0p53)
i5 : toExternalString toCC(numeric indeterminate, 5.0)
o5 = toCC(NotANumber,NotANumber)
i6 : toExternalString toCC(53, numeric indeterminate, 5)
o6 = toCC(NotANumber,.5p53e1)
Now we're consistent:
i1 : toExternalString toCC numeric infinity
o1 = toCC(numeric(53, infinity),numeric(53, infinity))
i2 : toExternalString toCC(numeric infinity, 5.0)
o2 = toCC(numeric(53, infinity),numeric(53, infinity))
i3 : toExternalString toCC(53, numeric infinity, 5)
o3 = toCC(numeric(53, infinity),numeric(53, infinity))
i4 : toExternalString toCC numeric indeterminate
o4 = toCC(numeric(53, NotANumber),numeric(53, NotANumber))
i5 : toExternalString toCC(numeric indeterminate, 5.0)
o5 = toCC(numeric(53, NotANumber),numeric(53, NotANumber))
i6 : toExternalString toCC(53, numeric indeterminate, 5)
o6 = toCC(numeric(53, NotANumber),numeric(53, NotANumber))
sorry I just noticed this PR. I will take a look now. (usual rant, why don't I get notified when a review is requested of me?)