DEV Community

Discussion on: Three bytes to an integer

Collapse
 
masterchef365 profile image
Duncan Freeman

Just FYI, the compiler will try to optimize operations like multiplications into bit shifts if it can (godbolt.org/z/9Pgztq), so type out what's clearest first! (In this case, it's probably the bit shifts anyway).

Collapse
 
wayofthepie profile image
wayofthepie

Agreed, that's why I went with the bit shifts. Shifting by 16 is a little less magical than multiplying by 65536 😄 neither are great in this case though and I went with what @lonami mentioned.

I need to drill deeper into the standard lib apis for sure!