How to get 32 bit mathematical output?

3 ビュー (過去 30 日間)
vivek k
vivek k 2013 年 2 月 26 日
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 件のコメント
Randy Souza
Randy Souza 2013 年 2 月 27 日
@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 2013 年 2 月 28 日
this is 1st time i m asking the question in in this forum, so not aware of caps lock. sorry for that

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2013 年 2 月 27 日
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 件のコメント
vivek k
vivek k 2013 年 2 月 28 日
thank you for responce. is it possible to get such value in matlab using symbolic toolbox?
Walter Roberson
Walter Roberson 2013 年 2 月 28 日
編集済み: Walter Roberson 2013 年 2 月 28 日
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

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by