Main Content

Cardinal numbers and magic numbers

Archive - Originally posted on "The Horse's Mouth" - 2006-12-14 16:48:54 - Graham Ellis

A cardinal number, in computing terms, is a term that's sometimes used to refer to a fixed condition - in other words, you might call a function with one parameter should of the usual number, and the final value will be assigned a cardinal number that can't occur there in reality. For example, you might call a function into which you input the number of children a person has, and if no value is entered the value could be set to a cardinal 999 that's checked for by the code. Should work, shouldn't it? After all - no-one could have 999 children. And it would work fine until the local headmaster, with a role of 1 short of 100 students, runs it on his hordes

A magic number is formed of certain bytes at the start of a file which signify the content type in the file. For example, the first three bytes of a .gif image file are GIF. The Unix and Linux file command uses magic numbers to identify content type.