[swift-evolution] [Proposal draft] Enhanced floating-point protocols
clattner at apple.com
Fri Apr 15 01:01:46 CDT 2016
On Apr 14, 2016, at 9:49 PM, Stephen Canon <scanon at apple.com> wrote:
>> On Apr 14, 2016, at 4:55 PM, Stephen Canon via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> Provide basic constants (analogues of C's DBL_MAX, etc.)
>> Nice, have you considered adding pi/e and other common constants? I’d really really like to see use of M_PI go away… :-)
> That’s a reasonable suggestion. I’m not sure if FloatingPoint is the right protocol to attach them to, but I’m not sure that it’s wrong either. I’d be interested to hear arguments from the community either way.
I’m not sure where the right place is either, I just want them :-) Seriously though, the notion of pi seems to make sense for both decimal and binary fp types, it seems base independent.
>> Swift supports instance and type members with the same names, but this is controversial, leads to confusion, and may go away in the future. It would be great to avoid this in your design.
> Interesting. Both are definitely useful, but Type(1).ulp is sufficiently simple that only having the instance member may be good enough. Otherwise, ulpOfOne or similar could work.
Either of those work for me.
>> I’m certainly not a floating point guru, but I would have expected significant to be of type RawSignificand, and thought that the significant of a nan would return its payload. Does this approach make sense?
>> … later: I see that you have this on the binary FP type, so I assume there is a good reason for this :-)
> Both are useful to have in practice. I have been attempting to keep the assumptions about representation to a minimum in the top-level FloatingPoint protocol.
>> I’m used to this being called a “Denormal”, but I suspect that “subnormal” is the actually right name? Maybe it would be useful to mention the “frequently known as denormal” in the comment, like you did with mantissa earlier.
> Yes, “subnormal” is the preferred IEEE 754 terminology, but I’ll add a note referencing “denormal” as well.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution