File Exchange

image thumbnail

NUM2IEEE

version 1.0 (2.07 KB) by

This function displays the IEEE double-precision representation of a double in MATLAB.

0 Downloads

Updated

View License

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)

Comments and Ratings (3)

Toby Driscoll

Toby Driscoll (view profile)

As 07 Sep comment says, this function gives incorrect results because of an unnecessary conversion to char.

Teja Muppirala

Teja Muppirala (view profile)

Hi how's it going Steve,

On line 19, you have:
number=num2str(number);

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:
number=num2str(number,100);

or something like that would be the only change needed, I think.

-Teja (LTC Application Engineer in Tokyo)

martin vernhout

works great!!! thanks

MATLAB Release
MATLAB 6.0 (R12)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Win prizes and improve your MATLAB skills

Play today