You can compute the actual exponent value by subtracting the bias value from the exponent value. For type float, the bias is 127 for type double, it is 1023. Lengths of Exponents and Mantissas Typeīecause exponents are stored in an unsigned form, the exponent is biased by half its possible value. If it is 1, the number is considered negative otherwise, it is considered a positive number. The most significant bit of any float or double is always the sign bit. The following table shows the number of bits allocated to the mantissa and the exponent for each floating-point type. Floating-Point Types Typeįloating-point variables are represented by a mantissa, which contains the value of the number, and an exponent, which contains the order of magnitude of the number. The following table shows the relationship between significance and storage requirements. The principal differences between the two types are the significance they can represent, the storage they require, and their range. You can declare variables as float or double, depending on the needs of your application. This representation gives a range of approximately 3.4E-38 to 3.4E+38 for type float. Since the high-order bit of the mantissa is always 1, it is not stored in the number. The mantissa represents a number between 1.0 and 2.0. Single-precision values with float type have 4 bytes, consisting of a sign bit, an 8-bit excess-127 binary exponent, and a 23-bit mantissa. Floating-point numbers use the IEEE (Institute of Electrical and Electronics Engineers) format.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |