strfromd(3) Library Functions Manual strfromd(3) strfromd, strfromf, strfroml - C (libc, -lc) #include int strfromd(char str[restrict .n], size_t n, const char *restrict format, double fp); int strfromf(char str[restrict .n], size_t n, const char *restrict format, float fp); int strfroml(char str[restrict .n], size_t n, const char *restrict format, long double fp); glibc (. feature_test_macros(7)): strfromd(), strfromf(), strfroml(): __STDC_WANT_IEC_60559_BFP_EXT__ fp str format. str n . The terminating null byte ('\0') is written if and only if n is sufficiently large, otherwise the written string is truncated at n characters. strfromd(), strfromf() strfroml() snprintf(str, n, format, fp); format. The format string must start with the character '%'. This is followed by an optional precision which starts with the period character (.), followed by an optional decimal integer. If no integer is specified after the period character, a precision of zero is used. Finally, the format string should have one of the conversion specifiers a, A, e, E, f, F, g, or G. , . , snprintf() . snprintf(3). NaN C99: fp NaN, +NaN -NaN f ( a, e, g), <>, <> <<-nan>>, . F ( A, E, G), <> <<-NAN>>. fp , [-]inf [-]INF. format . The strfromd(), strfromf(), and strfroml() functions return the number of characters that would have been written in str if n had enough space, not counting the terminating null byte. Thus, a return value of n or greater means that the output was truncated. attributes(7) POSIX Safety Concepts GNU C. +----------------------------+-------------------------------------------------------------------------------------------+--------------------------+ | | | | +----------------------------+-------------------------------------------------------------------------------------------+--------------------------+ |strfromd(), strfromf(), | | MT-Safe locale | |strfroml() | | | + +-------------------------------------------------------------------------------------------+--------------------------+ | | Async-signal safety | AS-Unsafe heap | + +-------------------------------------------------------------------------------------------+--------------------------+ | | | AC-Unsafe mem | +----------------------------+-------------------------------------------------------------------------------------------+--------------------------+ : . ISO/IEC TS 18661-1. strfromd() strfromf() strfroml() glibc 2.25. These functions take account of the LC_NUMERIC category of the current locale. 12.1 float , <<12.100000>>: #define __STDC_WANT_IEC_60559_BFP_EXT__ #include int ssize = 10; char s[ssize]; strfromf(s, ssize, "%f", 12.1); 12.3456 float , <<12.35>>: #define __STDC_WANT_IEC_60559_BFP_EXT__ #include int ssize = 10; char s[ssize]; strfromf(s, ssize, "%.2f", 12.3456); 12.345e19 double , <<1E+20>>: #define __STDC_WANT_IEC_60559_BFP_EXT__ #include int ssize = 10; char s[ssize]; strfromd(s, ssize, "%.E", 12.345e19); atof(3), snprintf(3), strtod(3) () Alexander Golubev , Azamat Hackimov , Hotellook, Nikita , Spiros Georgaras , Vladislav , Yuri Kozlov , Kirill Rekhov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. Linux 6.9.1 15 2024 . strfromd(3)