In this challenge, you will write a program to output how many decimal places are in the input string and trim the input if needed.
Examples
-12.32
2
32
0
3231.432
3
-34.0
0 -34
023
0 23
00324.230
2 324.23
10
0
00.3
1 0.3
0
0
-04.8330
3 -4.833
Rules
- Input will be a string which can be taken through, STDIN, function arguments or the closest equivalent
- Output can be through function return, STDOUT, or the closest equivalent.
- There is no limit on the size for the input integer except for your languages maximum string length.
- If the input has any unnecessary (leading or trailing) zeros:
- You should take them out
- Output the amount of decimal place in the new number
- Output the new number separated by a separator (e.g. space, newline, comma)
- Input will always match this RegEx:
-?\d+(\.\d+)?
, or if you don't speak RegEx:- There could be a
-
at the beginning implying a negative number. Then there will be at least one digit. Then there could be... a.
and some more digits. - To check if an input is valid, check here
- There could be a
- No Regex
This is code-golf so shortest code in bytes wins
0
. \$\endgroup\$