How to get 32 bit mathematical output?

3 Ansichten (letzte 30 Tage)
vivek k
vivek k am 26 Feb. 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 Kommentare
Randy Souza
Randy Souza am 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! ;-)
vivek k
vivek k am 28 Feb. 2013
this is 1st time i m asking the question in in this forum, so not aware of caps lock. sorry for that

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by