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

Function string_from_double

string/std_string.c:2914–2930  ·  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

2912 * @return A new String object containing the string representation of the float value.
2913 */
2914String* string_from_double(double value) {
2915 STRING_LOG("[string_from_double]: Function start. Converting double %f to String.", value);
2916
2917 char buffer[32];
2918 snprintf(buffer, sizeof(buffer), "%f", value);
2919
2920 String* result = string_create(buffer);
2921 if (result) {
2922 STRING_LOG("[string_from_double]: Successfully created String from double.");
2923 }
2924 else {
2925 STRING_LOG("[string_from_double]: Error - Memory allocation failed.");
2926 }
2927
2928 STRING_LOG("[string_from_double]: Function end.");
2929 return result;
2930}
2931
2932
2933/**

Callers

nothing calls this directly

Calls 1

string_createFunction · 0.85

Tested by

no test coverage detected