MCPcopy Create free account
hub / github.com/KaisenAmin/c_std / string_from_float

Function string_from_float

string/std_string.c:2886–2902  ·  view source on GitHub ↗

* @brief Creates a new String object from a float value. * * This function converts a floating-point number to its string representation * and returns a new String object containing this representation. * * @param value The float value to convert. * * @return A new String object containing the string representation of the float value. */

Source from the content-addressed store, hash-verified

2884 * @return A new String object containing the string representation of the float value.
2885 */
2886String* string_from_float(float value) {
2887 STRING_LOG("[string_from_float]: Function start. Converting float %f to String.", value);
2888
2889 char buffer[32];
2890 sprintf(buffer, "%f", value);
2891
2892 String* result = string_create(buffer);
2893 if (result) {
2894 STRING_LOG("[string_from_float]: Successfully created String from float.");
2895 }
2896 else {
2897 STRING_LOG("[string_from_float]: Error - Memory allocation failed.");
2898 }
2899
2900 STRING_LOG("[string_from_float]: Function end.");
2901 return result;
2902}
2903
2904/**
2905 * @brief Creates a new String object from a float value.

Callers

nothing calls this directly

Calls 1

string_createFunction · 0.85

Tested by

no test coverage detected