[swift-users] A sample Rational number type

Hooman Mehr hooman at mac.com
Wed Oct 5 14:30:06 CDT 2016


I encountered a bug in the standard library while working on an exact conversion from floating point types to my rational type <https://gist.github.com/hooman/6e08c48e1e06ee19e06e5b09f664f9be> (when you pass a tolerance of zero)

SR-2868 <https://bugs.swift.org/browse/SR-2868>: If the value of the floating point type is a power of two, its `significandWidth` property returns a nonsense value, because the behavior or Builtin.int_cttz_IntNN (used in countTrailingZeros property) is undefined for zero. 

The test suite should have included such special cases and caught this one.

> On Oct 3, 2016, at 9:08 AM, Dave Abrahams via swift-users <swift-users at swift.org> wrote:
> 
> on Sun Oct 02 2016, Hooman Mehr <swift-users-AT-swift.org <http://swift-users-at-swift.org/>> wrote:
> 
>>> On Oct 2, 2016, at 5:23 PM, Dave Abrahams via swift-users <swift-users at swift.org <mailto:swift-users at swift.org>> wrote:
>>> Presumably you mean:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161005/d5d37f7b/attachment.html>


More information about the swift-users mailing list