> On Jun 12, 2016, at 11:35 PM, Stephen Canon <[email protected]> wrote:
>
>
>> On Jun 10, 2016, at 5:20 PM, Darren Mo <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>>> – They’re not actually the maximum and minimum values of the type. In
>>> particular, that `max(Float.infinity, .max)` wouldn’t be `Float.max` is
>>> pretty seriously confusing.
>>
>> Infinity is a special value. I would argue that people who use infinity know
>> exactly what they are doing and would not be thrown by Float.infinity being
>> greater than Float.max. I am willing to bet that most regular users don’t
>> even know that infinity can be represented since it is rarely needed in
>> real-world usage.
>
> For clarity, what use cases do you have in mind where the largest finite
> value is more appropriate than infinity?
That… is a very good question.
My main use case was laying out fixed-width text. In the Objective-C days, I
would use CGFLOAT_MAX. I guess when I started to write the same code in Swift,
I didn’t stop to think about whether there was a better value. Now thanks to
you, I see that CGFloat.infinity is the clearest and most appropriate value.
Proposal cancelled. Thanks! ☺️
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution