Reply to post: Re: Sounds like a good idea

Keen to go _ExtInt? LLVM Clang compiler adds support for custom width integers

Andy Non Silver badge

Re: Sounds like a good idea

The one instance that sprang to mind when I wrote the above was when the original programmer was storing a value that never went negative, so he'd used the highest bit to store something else. Until the inevitable happened and it did store a negative value.

You can also have lots of fun compressing alpha-numeric characters. If the user's input data can only consist of A-Z, 0-9, comma, full stop and Space - a total of 39 characters, you can encode this as binary in 5 bits (0 - 38 decimal). Leaving 3 bits free per byte. Luxury! So you can start your next character using the remaining 3 bits from the previous byte and so on. It was a relief when RAM and disk space increased and such binary gymnastics were no longer required.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Biting the hand that feeds IT © 1998–2021