Due to the finite precision in floating point number represe

Due to the finite precision in floating point number representation, there are gaps between consecutive numbers. The size of these gaps depends on the size of the number and on the precision (e.g., double or single precision). Matlab provides the function eps(-), which returns, for a number, the distance to the next floating point number in the same precision. Using the form of double and single floating point number representation, explain the values you find for. Explain what the single precision format is. eps(1) eps (single(1)) eps(2^40) eps(single(2^40)) Matlab commands single, double, eps

Solution

Single-Precision Floating Point

MATLAB constructs the single-precision (or single) data type according to IEEE Standard 754 for single precision. Any value stored as a single requires 32 bits, formatted as shown in the table below:

Bits

Usage

31

Sign (0 = positive, 1 = negative)

30 to 23

Exponent, biased by 127

22 to 0

Fraction f of the number 1,f

Because MATLAB stores numbers of type single using 32 bits, they require less memory than numbers of type double, which use 64 bits. However, because they are stored with fewer bits, numbers of type single are represented to less precision than numbers of type double.

In MATLAB eps represents the precision of floating point numbers. Also it depends on the data type of the floating point numbers may be double or single.

In double, eps is 2^-52

In single, eps is 2^-23

Accordingly the eps value takes place.

Thus, MATLAB CANN’T RECOGNIZE A DIFFERENCE LESS THAN EPS.

Eps(1) is the smallest number such that 1+eps(1)>1.

For example 1+(1/2)eps(1)=1. That is addition of a number smaller than eps(1) does not make any changes. Difference between two numbers having distance less than eps(1) results in 0.

Bits

Usage

31

Sign (0 = positive, 1 = negative)

30 to 23

Exponent, biased by 127

22 to 0

Fraction f of the number 1,f

 Due to the finite precision in floating point number representation, there are gaps between consecutive numbers. The size of these gaps depends on the size of

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site