trailing_digits¶
-
mdtools.numpy_helper_functions.
trailing_digits
(n, digit=0)[source]¶ Get the number of trailing digits in an integer.
- Parameters
n (int) – The integer for which to count the trailing digits.
digit (int, optional) – The trailing digit to count. Must be positive.
- Returns
n_trailing – The number of trailing digits.
- Return type
Examples
>>> mdt.nph.trailing_digits(1, digit=0) 0
>>> mdt.nph.trailing_digits(1, digit=1) 1
>>> mdt.nph.trailing_digits(10, digit=0) 1
>>> mdt.nph.trailing_digits(10, digit=1) 0
>>> mdt.nph.trailing_digits(100, digit=0) 2
>>> mdt.nph.trailing_digits(100, digit=1) 0
>>> mdt.nph.trailing_digits(-100, digit=0) 2