| 203 | } |
| 204 | |
| 205 | void String_AppendFloat(cc_string* str, float num, int fracDigits) { |
| 206 | int i, whole, digit; |
| 207 | double frac; |
| 208 | |
| 209 | if (num < 0.0f) { |
| 210 | String_Append(str, '-'); /* don't need to check success */ |
| 211 | num = -num; |
| 212 | } |
| 213 | |
| 214 | whole = (int)num; |
| 215 | String_AppendUInt32(str, whole); |
| 216 | |
| 217 | frac = (double)num - (double)whole; |
| 218 | if (frac == 0.0) return; |
| 219 | String_Append(str, '.'); /* don't need to check success */ |
| 220 | |
| 221 | for (i = 0; i < fracDigits; i++) { |
| 222 | frac *= 10; |
| 223 | digit = (int)frac % 10; |
| 224 | String_Append(str, '0' + digit); |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | void String_AppendHex(cc_string* str, cc_uint8 value) { |
| 229 | /* 48 = index of 0, 55 = index of (A - 10) */ |
no test coverage detected