| 4978 | } |
| 4979 | |
| 4980 | String String::pad_decimals(int p_digits) const |
| 4981 | { |
| 4982 | String s = *this; |
| 4983 | int c = s.find("."); |
| 4984 | |
| 4985 | if (c == -1) |
| 4986 | { |
| 4987 | if (p_digits <= 0) |
| 4988 | { |
| 4989 | return s; |
| 4990 | } |
| 4991 | s += "."; |
| 4992 | c = s.length() - 1; |
| 4993 | } |
| 4994 | else |
| 4995 | { |
| 4996 | if (p_digits <= 0) |
| 4997 | { |
| 4998 | return s.substr(0, c); |
| 4999 | } |
| 5000 | } |
| 5001 | |
| 5002 | if (s.length() - (c + 1) > p_digits) |
| 5003 | { |
| 5004 | s = s.substr(0, c + p_digits + 1); |
| 5005 | } |
| 5006 | else |
| 5007 | { |
| 5008 | while (s.length() - (c + 1) < p_digits) |
| 5009 | { |
| 5010 | s += "0"; |
| 5011 | } |
| 5012 | } |
| 5013 | return s; |
| 5014 | } |
| 5015 | |
| 5016 | String String::pad_zeros(int p_digits) const |
| 5017 | { |
no test coverage detected