10
Float
- #include <iostream>
- #include <float.h>
- int main() {
- using namespace std;
- const int NBITS = 8; // bits in a byte
- int fbits = sizeof (float) * NBITS; // bits in a float
- cout << "\n A float takes:\t" << fbits << " bits:\n\t\t";
- cout << FLT_MANT_DIG - 1 << " bits for the mantissa\n\t\t ";
- cout << fbits - FLT_MANT_DIG << " bits for the exponent\n\t\t ";
- cout << 1 << " bit for the sign\n";
- cout << " with " << FLT_DIG << " significant digits\n";
- cout << " min value is " << FLT_MIN << endl;
- cout << " max value is " << FLT_MAX << endl;
- }
Comments