Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is float value guaranteed to be 0 when a float variable is initialized to 0.0?

In C, on any micro controller when we initialize a float variable to 0

float var = 0.0f;

Is 'var' exactly equal to zero or does it depend on the min & max float resolution of the processor?

like image 277
kp11 Avatar asked Jan 08 '23 21:01

kp11


1 Answers

Happily, zero is actually zero no matter what: IEEE-754 (the usual standard for floats) sets aside the all-zeroes bit pattern as meaning identically zero.

like image 77
nneonneo Avatar answered Jan 13 '23 16:01

nneonneo