> On Dec 19, 2015, at 11:04 PM, Dave Abrahams via swift-evolution
> <[email protected]> wrote:
>
>
>> On Dec 19, 2015, at 8:02 PM, Chris Lattner via swift-evolution
>> <[email protected] <mailto:[email protected]>> wrote:
>>
>>
>>> On Dec 19, 2015, at 7:43 PM, Jordan Rose via swift-evolution
>>> <[email protected] <mailto:[email protected]>> wrote:
>>>
>>> +1 to dropping the existing signatures and providing a consistent
>>> right-hand side.
>>>
>>> I'm a little concerned about not allowing Int as the shift type. Even
>>> though we disallow negative shifts, we generally encourage using 'Int' as
>>> the "vocabulary" type for integers, which means any shift by a non-constant
>>> amount might require a conversion. I do see that BigInts may be shifted by
>>> more than 2^64, however, so hardcoding Int wouldn't be right either.
>>
>> Unless it is somehow sparsely encoded, a bigint with more than 2^64 bits
>> couldn’t be held in memory.
>
> I don't believe bit shifting should be supported for BigInt anyway. The
> lossy semantics of bit shifting is pretty closely tied to fixed-width
> integers.
Yes, A BigInt type should probably eschew shift operators for this reason.
Instead, I would rather have either a sparse representation for powers of two
that can be used with the usual multiply / divide, or explicit
multiplyByTwoToThe( ) and divideByTwoToThe( ) functions (names to be
bikeshedded, obviously).
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution