MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / String_AppendFloat

Function String_AppendFloat

src/String.c:205–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205void 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
228void String_AppendHex(cc_string* str, cc_uint8 value) {
229 /* 48 = index of 0, 55 = index of (A - 10) */

Callers 15

TouchCtrls_UpdateScaleFunction · 0.85
TouchCtrls_ScaleFunction · 0.85
Float_DefaultFunction · 0.85
ES_GetCloudsSpeedFunction · 0.85
ES_GetWeatherSpeedFunction · 0.85
ChO_GetChatScaleFunction · 0.85
GuO_GetHotbarFunction · 0.85
GuO_GetInventoryFunction · 0.85
GuO_GetCrosshairFunction · 0.85
HS_GetSpeedFunction · 0.85
HS_GetJumpFunction · 0.85
HS_SetJumpFunction · 0.85

Calls 2

String_AppendFunction · 0.85
String_AppendUInt32Function · 0.85

Tested by

no test coverage detected