0

Someone gave me this challenge

See how large a type is by storing powers of 2 in this

list of types: float, double, long double. To determine if a number

will fit, start with 1.0, double it, then divide by 2 to see if you get

the previous number. For example, if a float is 4 bytes then (most likely)

when the value reaches 2^127 and you double and halve it, you will not get

2^127, so 2^128 will not fit, so print the message

2^127 will fit in a float on this platform.

Hint: The exponent to print out (127 in the

example) is just a count of how many times you doubled 1.0.

I'm new at C++ and just keep hitting a mental wall. How would you all do it?