The computer representation for binary floating-point numbers has been standardized by the IEEE in IEEE 754.IEEE 754-1985 officially adopted in 1985 and superseded in 2008 by IEEE 754-2008.

The standard defines:

- arithmetic formats: sets of binary and decimal floating-point data, which consist of finite numbers (including signed zeros and subnormal numbers), infinities, and special “not a number” values (NaNs)
- interchange formats: encodings (bit strings) that may be used to exchange floating-point data in an efficient and compact form
- rounding rules: properties to be satisfied when rounding numbers during arithmetic and conversions
- operations: arithmetic and other operations on arithmetic formats
- exception handling: indications of exceptional conditions (such as division by zero, overflow, etc.)

An IEEE 754 format comprises:

- Finite numbers, which may be either base 2 (binary) or base 10 (decimal). Each finite number is described by three integers: s = a sign (zero or one), c = a significand (or ‘coefficient’), q = an exponent. The numerical value of a finite number is:

(−1)^{s}×*c*×*b*^{q}

where b is the base (2 or 10). For example, if the sign is 1 (indicating negative), the significand is 12345, the exponent is −3, and the base is 10, then the value of the number is −12.345. - Two infinities: +∞ and −∞.
- Two kinds of NaN: a quiet NaN (qNaN) and a signaling NaN (sNaN). A NaN may carry a payload that is intended for diagnostic information indicating the source of the NaN. The sign of a NaN has no meaning, but it may be predictable in some circumstances.

Example:

0.15625_{10} = 1.5625 * 10^{-1 }= 0.00101_{2} = 1/8 + 1/32 = 1.01 * 2^{-3}

sign = 0 (0: positive, 1: negative)

biased exponent = 124 = -3 + bias (bias = 01111111_{2} = 127)

fraction = .01000…_{2}

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
#include <stdio.h> #include <limits.h> #include <float.h> int main () { printf("char size %d\n", CHAR_BIT); printf("char max %d\n", CHAR_MAX); printf("cha min %d\n", CHAR_MIN); printf("int size %d\n", sizeof(int)); printf("int min %d\n", INT_MIN); printf("int max %d\n", INT_MAX); printf("long size %ld\n", sizeof(long)); printf("long min %ld\n", LONG_MIN); printf("long max %ld\n", LONG_MAX); printf("short size %d\n", sizeof(short)); printf("short min %d\n", SHRT_MIN); printf("short max %d\n", SHRT_MAX); printf("unsigned char max %u\n", UCHAR_MAX); printf("unsigned long max %lu\n", ULONG_MAX); printf("unsigned int max %u\n", UINT_MAX); printf("unsigned short max %u\n", USHRT_MAX); printf("float size %ld\n", sizeof(float)); printf("float min %e\n", FLT_MIN); printf("float max %e\n", FLT_MAX); printf("double size %ld\n", sizeof(double)); printf("double min %e\n", DBL_MIN); printf("double max %e\n", DBL_MAX); return 0; } |

Sacs chanel D occasionHi, i think that i saѡ you visited my web sitfe thus і

came to “return tɦe favor”.I am tryimg to fiknd things to

improve mmy web site!I suppose its ok to use a few of

your іdeas!!