length method

int length()

Returns the number of digits in the string representation of the number.

For negative numbers, it includes the negative sign in the length. For decimal numbers, it includes the decimal point in the length.

Example:

123.length(); // Returns 3
(-123).length(); // Returns 4 (includes '-')
123.45.length(); // Returns 6 (includes '.')

NOTE: negative zero is removed when formatting. I.e. -0 becomes 0

Implementation

int length() => toString().length;