How to get 32 bit mathematical output?

3 visualizaciones (últimos 30 días)
vivek k
vivek k el 26 de Feb. de 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 comentarios
Randy Souza
Randy Souza el 27 de Feb. de 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 el 28 de Feb. de 2013
this is 1st time i m asking the question in in this forum, so not aware of caps lock. sorry for that

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 27 de Feb. de 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 comentarios
vivek k
vivek k el 28 de Feb. de 2013
thank you for responce. is it possible to get such value in matlab using symbolic toolbox?
Walter Roberson
Walter Roberson el 28 de Feb. de 2013
Editada: Walter Roberson el 28 de Feb. de 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

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by