[swift-evolution] Proposal: floating point static min / max properties

Matthew Johnson matthew at anandabits.com
Sat Dec 5 10:10:50 CST 2015


In the spirit of small commits and incremental change I have a very small proposal.  I am not sure if this belongs on the list or if small changes like this are ok as pull requests, but am starting here because it involves adding public API in the standard library.  

Integer types have static min / max properties, but floating point types currently do not.  The Darwin implementation is very straightforward.  

import Darwin

public extension Float {
   static let min = -FLT_MAX
   static let max = FLT_MAX
}

public extension Double {
   static let min = -DBL_MAX
   static let max = DBL_MAX
}

Is there interest in adding this?  If so, what is the right way to proceed?

Matthew


More information about the swift-evolution mailing list