How to get 32 bit mathematical output?

3 vues (au cours des 30 derniers jours)
vivek k
vivek k le 26 Fév 2013
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 commentaires
Randy Souza
Randy Souza le 27 Fév 2013
@vivek k: Please don't ask questions in all caps. It is the online equivalent of SHOUTING AT SOMEONE. Which is CONSIDERED RUDE! ;-)
vivek k
vivek k le 28 Fév 2013
this is 1st time i m asking the question in in this forum, so not aware of caps lock. sorry for that

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 27 Fév 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 commentaires
vivek k
vivek k le 28 Fév 2013
thank you for responce. is it possible to get such value in matlab using symbolic toolbox?
Walter Roberson
Walter Roberson le 28 Fév 2013
Modifié(e) : Walter Roberson le 28 Fév 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

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by