c - Why floating point does not start from negative numbers when it exceeds its range? -


as know when integer varible exceeds range starts other end negative numbers.
example

int a=2147483648; printf("%d",a); 

output:
-2147483648 (as expecting)

now tried same floating points.
example

float a=3.4e39;//as largest float 3.4e38 printf("%f",a); 

outout:
1.#inf00 (i expecting negative float value)

didn't above output know represents positive infinity.
question why not start other end(negative values integers)?

floating point numbers stored in different format integer numbers, , don't follow same over-/under-flowing mechanics.

more specifically, binary bit-pattern 2147483648 1000000000000000 in two's complement system (like 1 used on modern computers) same -2147483648.

most computers today uses ieee754 format floating point values, , handled quite differently plain integers.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -