How to compute dBFS?
It is really quite simple for values between 1 and -1:

valueDBFS = 20*log10(abs(value))


If you have values between another range, for example 16bit, then it's:

valueDBFS = 20*log10(abs(value)/32768)


(because 16bit signed has values between -32768 and +32767, e.g. 2^15=32768)

And so the general formula is:

valueDBFS = 20*log10(abs(value)/maxValue)


The code examples are given in MATLAB code.