There are new format specifiers for intN_t
types, for example %"PRIiN"
and %"SCNiN"
, for printf
and scanf
families of functions.
What are, if any, the new format specifiers for float_t
and double_t
? (defined in math.h
)
Can I -safely- use %f
and %lf
? I don't think so, because float_t
is only at least as large as float
, but could be defined as long double
.
As nobody answered, and I don't find the answer anywhere, may it be a bug in C?
To be cautious and portable you could us %Lf
in your printf
control string and cast values of type float_t
or double_t
to long double
.
Edited:
Format specifier for long double is %Lf
and not %lf
You have to be more cautious for scanf because in that case casting won't help you.
Alternatively you could define your own printf
and scanf
format specifiers for float_t
and double_t
, making use of the FLT_EVAL_METHOD
[1] macro to find out which built-in types that float_t
and double_t
are respectively equivalent to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With