[swift-evolution] protocol-oriented integers (take 2)

David Sweeris davesweeris at mac.com
Sun Jan 29 12:29:28 CST 2017


> On Jan 13, 2017, at 12:47, Max Moiseev via swift-evolution <swift-evolution at swift.org> wrote:

> DoubleWidth
> The DoubleWidth<T> type allows to create wider fixed-width integer types from the ones available in the standard library.
> 
> Standard library currently provides fixed-width integer types of up to 64 bits. A value of DoubleWidth<Int64> will double the range of the underlying type and implement all the FixedWidthInteger requirements. Please note though that the implementation will not necessarily be the most efficient one, so it would not be a good idea to use DoubleWidth<Int32>instead of a built-in Int64.
> 

What about having a "CompoundBinaryInteger<T,U>" type, and then do "typealias DoubleWidth<T> = CompoundBinaryInteger<T,T>"? That would make it easier to have, say, 40-bit ints, "CompoundBinaryInteger<Int8,Int32>", while still having the convenience of "DoubleWidth<T>".

- Dave Sweeris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170129/0575b45a/attachment.html>


More information about the swift-evolution mailing list