Condition Evaluation Utility

After you run a command in UNIX shell (bourne, bash, etc), $? has the exit code (return value) of the prior run command: $? Expands to the exit status of the most recent pipeline. Shell scripting is a bit weird in that the return value of a program is evaluated as true if it’s 0 and false if it’s non-zero. This is useful as by convention unix commands return 0 on success or any other integer code to map to specific error conditions. ...

December 6, 2025 · 5 min

ASCII case bit twiddling

If you pay a special sort of attention, you may notice that the upper-case and lower-case alphabet characters on the ASCII table are always exactly offset from each other by 32. For example, upper-case A is 65, while the lowercase a is 97 As such the way the binary place value works out, you can manipulate the case of a character by setting or clearing the sixth bit… (2^5 = 32, we start counting bits and everything at 0, we’re programmers!) Decimal 32 expressed as hexadecimal is 0x20 and expressed as binary is 00100000 ...

December 10, 2024 · 4 min

Initialize your variables

There’s no shortage of material that explains variables in C should be initialized… but I’ve often found the explanation of why to be somewhat lacking. Where do the initial values of a variable come from if you don’t explicitly initialize? ...

August 17, 2024 · 3 min

Guess the number...

A quick demonstration of how one can use a debugger to interactively inspect variables in a running program… ...

April 5, 2024 · 2 min