Questions tagged [null]

Null means *nothing* or *unknown*, depending on context. Please use the "sql-null" tag for SQL specific questions.

"Null" has different meanings depending on context.

Set theory

Null is another name for the empty set, denoted by the symbol ∅. For this reason, some programming languages use null or nil for the empty list or empty tuple. Lisp uses nil to mean the empty list and the boolean value false.

Pointers and References

Null (or sometimes nil or None), in programming languages that support it, is the value of an uninitialized variable, a pointer that doesn't point to a meaningful memory address, or an object that fails to respond to any message.

Nullable references were invented by C.A.R. Hoare in 1965 as part of the Algol W language. Hoare later described his invention as a "billion-dollar mistake".

For more information, see Null pointer.

Agreeing with Hoare's sentiment, many languages don't have a special null value, choosing to use optional types instead.

Relational Databases

NULL as a special marker in SQL or a relational database stands in place of a value that is missing, or in a join means "no corresponding row." The operators IS NULL and IS NOT NULL are required for comparisons to a literal null: other comparisons between NULL and any value evaluate to "unknown."

For more information, see Null (SQL).

ASCII

Null or NUL is the name given to the character with ASCII code zero (0) - i.e. hex 00. In some languages, notably C, NUL is used to mark the end of a character string.

For more information, see Null character.

16208 questions
72
votes
8 answers

Why does .ToString() on a null string cause a null error, when .ToString() works fine on a nullable int with null value?

selectedItem has two fields: int? _cost string _serialNumber In this example, _cost and _serialNumber of selectedItem are BOTH null. I am reading through the fields of selectedItem via their properties, and filling in textboxes with their values,…
CptSupermrkt
  • 6,844
  • 12
  • 56
  • 87
72
votes
8 answers

How can I change NULL to 0 when getting a single value from a SQL function?

I have a query that counts the price of all items between two dates. Here is the select statement: SELECT SUM(Price) AS TotalPrice FROM Inventory WHERE (DateAdded BETWEEN @StartDate AND @EndDate) You can assume all of the tables have been set up…
Matt
  • 5,249
  • 12
  • 40
  • 45
71
votes
8 answers

How to test for $null array in PowerShell

I'm using an array variable in PowerShell 2.0. If it does not have a value, it will be $null, which I can test for successfully: PS C:\> [array]$foo = $null PS C:\> $foo -eq $null True But when I give it a value, the test for $null does not return…
Mark Berry
  • 17,843
  • 4
  • 58
  • 88
71
votes
8 answers

How can I check if 'grep' doesn't have any output?

I need to check if the recipient username is in file /etc/passwd which contains all the users in my class, but I have tried a few different combinations of if statements and grep without success. The best I could come up with is below, but I don't…
Duncan
  • 719
  • 1
  • 6
  • 7
70
votes
9 answers

Is there a null std::ostream implementation in C++ or libraries?

I'm looking for a std::ostream implementation that acts like /dev/null. It would just ignore anything that is streamed to it. Does such a thing exist in the standard libraries or Boost? Or do I have to roll my own?
paperjam
  • 8,321
  • 12
  • 53
  • 79
70
votes
5 answers

getElementById() returns null even though the element exists

I'm trying to get the element with getElementById(), but it returns null even though the element exists. What am I doing wrong? blah