Learn R Programming

descutils (version 1.0)

decimalplaces: Count Decimal Places in a Number String

Description

Computes the number of decimal places in the character representation of a number.

Usage

decimalplaces(x)

Value

Integer: The number of digits after the decimal point; 0 if there is no decimal point.

Arguments

x

A character string representing a number.

Examples

Run this code
decimalplaces("3.141")   # returns 3
decimalplaces("42")      # returns 0

Run the code above in your browser using DataLab