www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Unsigned comparison operators

reply Cecil Ward <d cecilward.com> writes:
I love the D >>> operator and I use it a lot. So much safer than 
the chaos in C.

I would absolutely love to have unsigned comparison operators in 
D. Do you agree? What on earth would the syntax be like?

Yes, I could write a generic function or something, but the 
result would look ugly. And I would have to be very careful not 
to screw up type conversions (although i’m pretty sure there is 
some help available in the rtl to assist in getting the job done 
safely).
Sep 29
parent Stefan Koch <uplink.coder googlemail.com> writes:
On Friday, 29 September 2017 at 11:20:13 UTC, Cecil Ward wrote:
 I love the D >>> operator and I use it a lot. So much safer 
 than the chaos in C.

 I would absolutely love to have unsigned comparison operators 
 in D. Do you agree? What on earth would the syntax be like?

 Yes, I could write a generic function or something, but the 
 result would look ugly. And I would have to be very careful not 
 to screw up type conversions (although i’m pretty sure there is 
 some help available in the rtl to assist in getting the job 
 done safely).
I have a hard time imagining a use case. The reason why he have signed shift in the first place is to make the (n >> m) be equivalent to n * (2^^m)
Sep 29