Sentinel Values

“Halt!  Who goes there?”  The sentinel on duty at the castle was wide awake.  Our sentinel values don’t carry weapons or defend ramparts, but they perform useful guarding tasks in our programs.  In computer science, a sentinel value is a value that would not normally occur in input and serves as a marker of the end of input.  Occasionally they can also be in a location in an array, not at the end of the data, but representing when a condition has been met.  Two examples are discussed below.

Continue reading “Sentinel Values”

ASCII Fun

ASCII art like the greeting above is common, but ASCII characters are useful for a lot more.  Represented in a Java in a manner identical to the first 128 unsigned integers, they can be substituted for ints at any time, and ints 32 -126 inclusive can be cast to chars and printed.  While limited compared to the unicode set of characters (ASCII can’t represent á, for example), ASCII is the workhorse of most file systems.

Continue reading “ASCII Fun”