[swift-evolution] [Proposal] Add floor() and ceiling() functions to FloatingPoint

Haravikk e-mail at haravikk.me
Sat Jun 25 13:55:26 CDT 2016


> On 25 Jun 2016, at 11:06, Karl via swift-evolution <swift-evolution at swift.org> wrote:
> 
> floor() and ceil(), exactly like C. ceiling() is more descriptive and is a mathematical term of art <http://mathworld.wolfram.com/CeilingFunction.html>.
> nextIntegralUp() and nextIntegralDown() are more descriptive still, but possibly misleading as (4.0).nextIntegralUp() == 4.0
I'm in favour of these capabilities being there, but in terms of naming I've often wondered why it can't just be part of a rounding group of methods like so:

	func roundedUp() -> Self { … }
	func roundedUp(withPrecision:Int) -> Self { … }
	func roundedDown() -> Self { … }
	func roundedDown(withPrecision:Int) -> Self { … }

Since the methods with implied precision of zero are equivalent to floor and ceiling surely? I know floor and ceiling are pretty common terms, but they're just a form rounding when it comes down to it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160625/fac10d38/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4634 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160625/fac10d38/attachment.p7s>


More information about the swift-evolution mailing list