Null values are a particular type of values that are used to indicate cells where the value for a given layer is not defined. Understanding how to use them is important to avoid wrong results when performing analyses but also to use them as a tool to get better and more correct results. This recipe explains some of the fundamental ideas about null values in raster layers.
The watershed.tif layer contains the area of a watershed. Cells inside the watershed are cells from which water will eventually flow into the outlet point of the watershed. The remaining cells belong to a different watershed. To mask the DEM with the watershed mask, follow these steps:
watershed.tif layer.no data.

Only the cells with a value of 1 have been considered, and the average value in the layer is equal to 1.
The layer has 610 columns and 401 rows, but the total number of valid cells is much lower than 610 x 410. These are the cells that have been used to compute the statistics.
Raster layers always cover a rectangular region. However, in some circumstances, the land object that the layer represents might not be rectangular. This might be due to a purely geophysical reason (imagine a layer with water temperature that contains non-water cells), political ones (a layer with a DEM of a given country with no data available for a neighboring country), or many others. In any case, a value is needed for these cells to indicate that no data is available. An arbitrary value is selected and used. As such, this is usually a value that is not a logical and/or feasible value for the variable that is stored in the layer.
In the case of the example layer, the value used is -99999, which is the default value set for no-data values. This means that, when the identify tool shows no data, it has actually selected a value of -99999 in this case.
Algorithms in the Processing framework systematically ignore no-data cells, and do not use their values. You can clearly see this in the preceding example. A large part of the cells in the layer have a value of 1 (the ones that belong to the watershed), but many of them have a value of -99999. The average value of the cells should then be different from 1, but as -99999 is defined as the no-data value, all cells with this value are ignored. The average of the layer is, therefore, equal to 1.
Null values should be considered not only when performing an analysis, but also when we just want to render a layer that contains them.
Null values are also considered separately when rendering a raster layer. You can choose to select them using a given color (as set by the current color palette), or to not render them at all. To make all cells with null values transparent, open the layer properties and go to the Transparency section. Make sure that the No data value checkbox is checked, as shown in the following screenshot:
