The estimation of the slope (b-value) of the frequency magnitude distribution of earthquakes is based on a formula derived by Aki decades ago, assuming a continuous exponential distribution. However, as the magnitude is usually provided with a limited resolution, its distribution is not continuous but discrete. In the literature this problem was initially solved by an empirical correction (due to Utsu) to the minimum magnitude, and later by providing an exact formula such as that by Tinti and Mulargia, based on the geometric distribution theory. A recent paper by van der Elst showed that the b-value can be estimated also by considering the magnitude differences (which are proven to follow an exponential discrete Laplace distribution) and that in this case the estimator is more resilient to the incompleteness of the magnitude dataset. In this work we provide the complete theoretical formulation including i) the derivation of the means and standard deviations of the discrete exponential and Laplace distributions; ii) the estimators of the decay parameter of the discrete exponential and trimmed Laplace distributions; and iii) the corresponding formulas for the parameter b. We further deduce iv) the standard 1-sigma confidence limits for the estimated b. Moreover, we are able v) to quantify the error associated with the Utsu minimum-magnitude correction. We tested extensively such formulas on simulated synthetic datasets including complete catalogues as well as catalogues affected by a strong incompleteness degree such as aftershock sequences where the incompleteness is made to vary from one event to the next.