Like digits10() but for signed values. */
| 295 | |
| 296 | /* Like digits10() but for signed values. */ |
| 297 | uint32_t sdigits10(int64_t v) { |
| 298 | if (v < 0) { |
| 299 | /* Abs value of LLONG_MIN requires special handling. */ |
| 300 | uint64_t uv = (v != LLONG_MIN) ? |
| 301 | (uint64_t)-v : ((uint64_t) LLONG_MAX)+1; |
| 302 | return digits10(uv)+1; /* +1 for the minus. */ |
| 303 | } else { |
| 304 | return digits10(v); |
| 305 | } |
| 306 | } |
| 307 | |
| 308 | /* Convert a long long into a string. Returns the number of |
| 309 | * characters needed to represent the number. |
no test coverage detected