function d = digit(a, n);
% digit(a,n) returns an array the same size as a, containing
% the nth digit from the right, assuming a is an array of integers.
% It is intended for use with quality flags in CTD and bottle files.

x = floor(a/(10^(n-1)));
xx = 10*floor(x/10);
d = round(x-xx);

