tags:

views:

212

answers:

2

Why doesn't C++ have <cstdfloat> header for floats like it has <cstdint> for integers?

EDIT :

By <cstdfloat> I mean header that provides typedefs for float and double. Much like qreal typedef in Qt. Hope my question is clear now.

+3  A: 

Are you perhaps looking for <float.h> and its C++ brother <cfloat> instead?

Adam Rosenfield
<float.h> is a different thing. I am talking about header that provides typedefs for float and double. Much like qreal typedef in Qt. Hope you understand my question now.
missingfaktor
Then you should specify that in your question. Your question is incredibly vague.
Adam Rosenfield
@Rosenfield : Sorry. Edited my question now.
missingfaktor
+3  A: 

Often an application needs exactly 16 bits for an integer for, say, a bitfield, but having exactly 16 bits for a float is kind of useless. Manipulating bits in an integer is easy, so having exactly 16 is nice. Manipulating bits in a float requires casting it to an integer, making a float16 type rather extraneous.

By the same token, having an integral type capable of storing (and also performing math on) pointers is useful, but who ever needs to convert a pointer value to a floating point value, then perform floating point math on it, then convert it back to a pointer?

The point is that most of the functionality in stdint.h (or cstdint for C++, except that stdint.h is a C99 header and isn't technically part of C++) doesn't apply to floating point values.

Chris Lutz