How to get 32 bit mathematical output?
2 views (last 30 days)
Show older comments
I am computing a series of equations and presently I'm getting a 15 bit floating point o/p, I need it in 32 bit and 64 bit.
4 Comments
Randy Souza
on 27 Feb 2013
@vivek k: Please don't ask questions in all caps. It is the online equivalent of SHOUTING AT SOMEONE. Which is CONSIDERED RUDE! ;-)
Accepted Answer
Walter Roberson
on 27 Feb 2013
0.984807753012208 is 15 digits, not 15 bits. You are also missing printing out some of the digits: use
sprintf('%.99g\n', TheVariable)
to see the full list of digits.
Each decimal digit corresponds to log2(10) bits, which is just under 3 1/3 bits per decimal digit. 15 decimal digits therefore corresponds to about 49 bits. But really it is 16 digits you are getting: the next in sequence happens to be 0 so it is omitted from the printout. 16 decimal digits corresponds to 53 bits of accuracy. The remaining bits in a 64 bit double precision word correspond to sign information and to the exponent (... x 2^(-1) in this particular case.)
So you are already getting full 64 bit accuracy.
4 Comments
Walter Roberson
on 28 Feb 2013
Edited: Walter Roberson
on 28 Feb 2013
I do not have the MuPAD symbolic toolbox to test with to be absolutely sure, but
vpa( cos(sym(10) * sym('pi') / sym(180)), 64 )
should produce the symbolic result (you will not be able to store the result in a double precision number, of course)
0.9848077530122080593667430245895230136706432517198424187900257524
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!