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 https://www.mathworks.com/content/dam/mathworks/mathworks-dot-com/company/newsletters/news_notes/pdf/Fall96Cleve.pdf )
Steven Lord (2020). NUM2IEEE (https://www.mathworks.com/matlabcentral/fileexchange/2996-num2ieee), MATLAB Central File Exchange. Retrieved .
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
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!