How to determine w/o conversions that a given floating constant can be represented?
Sample code:
#define FLOATING_CONSTANT1 2147483647.0f
#define FLOATING_CONSTANT2 2147483520.0f
bool b1 = FLOATING_CONSTANT_CAN_BE_REPRESENTED( FLOATING_CONSTANT1 ); // false
bool b2 = FLOATING_CONSTANT_CAN_BE_REPRESENTED( FLOATING_CONSTANT2 ); // true
"w/o conversions" seems to be an unnecessary restrictive requirement, but something to get OP started and a test harness for others.
Output
Notes:
If the fractional portion of a FP constant does not end in
5or0, it cannot be exactly converted to afloat/double.When exact FP constants are needed, the first step is to consider hexadecimal-floating-constant such a
0x1.23CDp12f