What is "null"

In computer programming, null is a special value for a pointer (or any other type of reference) that indicates that this pointer intentionally does not refer to an object (null pointer). Often, in programs written in the C language, a binary value 0 (zero) is used as a null value, since most operating systems consider it an error to access a memory address "so low".

Meanings in other areas of Computer Science

The null value is used in other disciplines of Computer Science (often with variations null or nil):

  • In Unix-like operating systems, the /dev/null device is a reference to the null device, a special file that discards data sent to it and that does not return data to the processes that read it. In DOS and Microsoft Windows systems the NUL device has similar behaviour.
  • In the C0 control code set, defined in ISO646 and used in the ASCII table and the Unicode encoding standard, the 0-value code is called null character.
  • In some programming languages, such as LISP, Pascal (Delphi and some variations of Pascal use "null" for the "null variant", fact that causes confusions that lead to errors, when the "null" is used in place of "nil") and in the Ruby programming language, this value is called nil.
  • In many disciplines, the concept of null allows the logic of multiple values, with null indicating "unknown value". A SQL database language uses "Null" in this way, as makes Visual Basic (with the term "Nothing") and its derivatives. In this model, an expression that depends on the value of a Null operand will return Null (Visual Basic) or "unknown value" (SQL). Therefore, for any A, the expression "A = Null" and "A <> Null" does not result in true or false. However, the boolean operation "A and false" produces false and, similarly, "A or true" is true when A equals Null, due to the fact that these expressions do not depend on the value of A. (Some implementations of the SQL language can consider A = Null equal to true if A has value Null).
  • In some programming languages, the null character can mean the end of a string.