food for thought - swift 5 released - bottom types, string interpolation, and stuff.
lithium iodate
whatdoiknow at doesntexist.net
Sun Apr 14 15:19:38 UTC 2019
On Sunday, 14 April 2019 at 15:01:22 UTC, Julian wrote:
> On Sunday, 14 April 2019 at 13:28:13 UTC, lithium iodate wrote:
>> On Sunday, 14 April 2019 at 13:23:27 UTC, Adam D. Ruppe wrote:
>>> On Sunday, 14 April 2019 at 13:19:22 UTC, lithium iodate
>>> wrote:
>>>> I personally would expect bitwise operations to operate on
>>>> the underlying bit pattern instead of its two's-complement
>>>> equivalent representation.
>>>
>>> Aren't those the same thing?
>>
>> For the inbuilt integral types? Sure. For custom integral
>> types? Not necessarily.
>> When dealing with protocols and compression you might get into
>> the situation of defining an integer with some special coding
>> as internal representation.
>
> How would adding isOdd to phobos change this?
By selecting suitable treatment for the given type:
inbuilt integer -> &1 (or whatever)
does it provide a isOdd function? -> call isOdd of that type
perhaps it somehow declared that oddity can't be determined ->
fail fast and loud
else try %2 != 0
else fail fast and loud
none of which include making possibly incorrect assumptions about
its representation.
More information about the Digitalmars-d
mailing list