Skip to contents

This function calculates the number of decimal places in a numeric value. It is designed to work with numeric inputs that can be coerced to character format.

Usage

NDecimals(x)

Arguments

x

A numeric value or a string that represents a numeric value.

Value

An integer representing the number of decimal places in the input value. If the input value does not have any decimal places, the function returns 0.

Author

Ahmed El-Gabbas

Examples

NDecimals(x = "13.45554545")
#> [1] 8

# -------------------------------------------

NDecimals(x = 15.01500)
#> [1] 3

NDecimals(x = '15.01500')
#> [1] 5

# -------------------------------------------

NDecimals(x = 13.45554545)
#> [1] 8