🔒 Locked
Float vs. Double?
Advertisement
Original Post
Just a quick question.......Is the difference between float and double a difference in size? If so....what are the sizes?
Also in Visual C++ 6.0....how is this interrepted?
0.001 <- as a float or double?
Thanks,
fallout2600
***The mind is the enemy....
Shurcool,
Thanks....the printf was what I needed.
fallout2600
Thanks....the printf was what I needed.
fallout2600
From an old edition of MSDN of mine:
In a nutshell, doubles have twice the size and twice the precision of a float.
"If people are good only because they fear punishment and hope for reward, then we are a sorry lot indeed." - Albert Einstein
quote:
Double precision values with double type have 8 bytes. The format is similar to the float format except that it has an 11-bit excess-1023 exponent and a 52-bit mantissa, plus the implied high-order 1 bit. This format gives a range of approximately 1.7E-308 to 1.7E308 for type double.
In a nutshell, doubles have twice the size and twice the precision of a float.
"If people are good only because they fear punishment and hope for reward, then we are a sorry lot indeed." - Albert Einstein
I get that doubles are 2 times in size than floats.....but in Visual C++ 6.0.............what does the compiler interrept this as?
x = 0.001; <- will this be a float or double value
x = 0.001f; <- or do I have to specify the f?
Thanks for the replies.......
fallout2600
x = 0.001; <- will this be a float or double value
x = 0.001f; <- or do I have to specify the f?
Thanks for the replies.......
fallout2600
That''s the C specification that says floating point numbers default to double precision - you can override with by postpending an ''f'' to set it to float/single precision.
Typical ranges of float and double.
These values may vary on different computers and/or compilers.
float -3.4E-38 to 3.4E+38
double -1.7E-308 to 1.7E+308
These values may vary on different computers and/or compilers.
float -3.4E-38 to 3.4E+38
double -1.7E-308 to 1.7E+308
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement