#Concise way to specify a negative usize value
1 messages · Page 1 of 1 (latest)
make a function for it?
-x is represented as ~@(uN, x) + 1
Hard to guess what that does without a comment
it's the relationship that defines twos complement
would this work?
@as(usize, 0) -% 1
it should
Yeah, I had this idea, still don't find it too readable.
So far seems the best option 😄
0 -% x is definitely as readable as you're going to get it
yeah I find it readable, but functions are good too
My issue with readability of the subtraction approach is that it doesn't directly express the idea, but rather makes a (relatively obvious, but nevertheless) equivalent representation of it. I want a negative number, but I have to write a subtraction from zero instead. This is not how I personally define readability.
yep, no getting away from giving it a type
giving it a type is not my issue, the length of the original expression is
I had no idea this was a thing lol
NB. Please don't suggest ideas like inverting all bits of a zero, I need a generic way to specify various negative values.