C99 states integer types like uint32_t, int16_t etc, where it’s easy to see the number of bits used. Good to know in for instance embedded programming.
I have not found any similar types for floating point values. Is there a standard? If not, why?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I found the answer in Any guaranteed minimum sizes for types in C?
Quoting Jed Smith (with corrected link to C99 standard):
Yes, the values in
float.handlimits.hare system dependent. You should never make assumptions about the width of a type, but the standard does lay down some minimums. See §6.2.5 and §5.2.4.2.1 in the C99 standard.For example, the standard only says that a
charshould be large enough to hold every character in the execution character set. It doesn’t say how wide it is.For the floating-point case, the standard hints at the order in which the widths of the types are given:
§6.2.5.10
They implicitly defined which is wider than the other, but not specifically how wide they are. “Subset” itself is vague, because a
long doublecan have the exact same range of adoubleand satisfy this clause.This is pretty typical of how C goes, and a lot is left to each individual environment. You can’t assume, you have to ask the compiler.