[swift-evolution] [Proposal draft] Enhanced floating-point protocols

Chris Lattner clattner at apple.com
Fri Apr 15 01:05:17 CDT 2016


> On Apr 14, 2016, at 11:01 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
> 
> On Apr 14, 2016, at 9:49 PM, Stephen Canon <scanon at apple.com <mailto: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.

Incidentally, if you make pi and e be static members of the type, we should get a pretty fluent style, along the lines of:

	let x = someDouble * 2 * .pi

I agree that there is a concern about deciding “which” constants to include.  I’ll let you and the numeric elite figure that out :-)

-Chris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160414/c7a17a1e/attachment.html>


More information about the swift-evolution mailing list