This function displays the IEEE double-precision representation of a double in MATLAB. If used with the Symbolic Math Toolbox, it can also display the exact number represented by that IEEE floating point number (which may not be exactly the same as the input; see the Fall 1996 Cleve's Corner article at http://www.mathworks.com/company/newsletter/pdf/Fall96Cleve.pdf)
As 07 Sep comment says, this function gives incorrect results because of an unnecessary conversion to char.
Hi how's it going Steve,
On line 19, you have:
but this will return a string with fewer decimal places than is necessary to represent the actual machine number that was input.
For example, if I were to do
>>[s,e,m] = num2ieee(sqrt(2))
then the string on line 19 becomes '1.4142' and I get a wrong result (at least that's what happens on R2009a and R2009b).
Changing line 19 to:
or something like that would be the only change needed, I think.
-Teja (LTC Application Engineer in Tokyo)
works great!!! thanks