Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
it's beyond me how most modern languages don't have a feature like C's bit structs
And even in C/C++ it's only a half baked feature since it relies on compile specifics -
Bit shifting is only math in terms of multiplying and dividing unsigned integers by two.
(And it's a sensible optimization where applicable).
All other uses are for boolean comparison reasons. -
As long as it's not absolutely necessary for it to be super fast and super compact, I'd rather use a set type with enum values.
It makes you feel less than a hacker but the code is so much better. -
Do yourself one better and just add integer powers of two in lieu of bit twiddling. It's the same thing anyway.
-
jassole18401y@LotsOfCaffeine I have this complaint too. Bit Fields are lot intuitive to work with than using masks, shifts
-
@TheCommoner282
Yes, I know it. It's one iteration of newton's method, and guess what it does? Exactly, take a float, interpret as int, and shift right, effectively halving the exponent (which handles the square root) and then using the constant to adjust the mantissa. -
had an old collegue that used this when it could have more clearly been expressed in a switch statement. mind you, not less LINES of code, but more CLEAR
you choose what is more important
i fucking hate bit shifting operation fuckery
fuck your clever math and shit
also documenting what represents what in an idiot proof way so i can easily consume it
rant