MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
Asked by Venkatraman on 19 Mar 2013

If I type this: 0.24703282292062327209e-323

I get: 4.9407e-324

If I type this: 0.24703282292062327208e-323

I get: 0

What is the minimum non zero number that matlab uses. It is obviously not realmin = 2.2251e-308 or eps 2.2204e-16.

How can find the true minimum non zero number?

*No products are associated with this question.*

Answer by James Tursa on 19 Mar 2013

Accepted answer

realmin returns the smallest normalized number. To get the smallest denormalized number (not as much precision as a normalized number):

typecast(uint64(1),'double')

Or for single precision

typecast(uint32(1),'single')

Venkatraman on 19 Mar 2013

Thank you. Can you elaborate a little bit about normalized versus denormalized number?

It seems to me that for comparing a>b matlab uses denormalized threshold.

Walter Roberson on 19 Mar 2013

Normalized numbers use the floating point scheme where the exponent varies to keep the first bit of the mantissa a "1" bit, and that "1" bit is not actually stored because it is always implied. As long as the scheme lasts, the number of "useful" bits in the mantissa stays the same as the number gets smaller. Dividing by 2 would result in a decrease in the exponent but no change in the mantissa.

Denormalized numbers use a fixed exponent (one less than for the minimum for normalized numbers) and the leading "1" bit is stored explicitly and will not necessarily be at the beginning of the number. As the leading "1" bit keeps getting further and further right as the numbers go smaller in denormalized numbers, the number of "useful" bits available for the mantissa keeps getting smaller. Dividing by 2 keeps the exponent the same but requires that the mantissa be shifted right (losing the bottom bit.)

Answer by Walter Roberson on 19 Mar 2013

>> a = sprintf('%.800g', eps(realmin))

a =

4.940656458412465441765687928682213723650598026143247644255856825006755072702087518652998363616359923797965646954457177309266567103559397963987747960107818781263007131903114045278458171678489821036887186360569987307230500063874091535649843873124733972731696151400317153853980741262385655911710266585566867681870395603106249319452715914924553293054565444011274801297099995419319894090804165633245247571478690147267801593552386115501348035264934720193790268107107491703332226844753335720832431936092382893458368060106011506169809753078342277318329247904982524730776375927247874656084778203734469699533647017972677717585125660551199131504891101451037862738167250955837389733598993664809941164205702637090279242767544565229087538682506419718265533447265625e-324

James Tursa on 20 Mar 2013

On PC's the above won't work and you will have to do this:

num2strexact(eps(realmin))

The NUM2STREXACT function can be found on the FEX here:

http://www.mathworks.com/matlabcentral/fileexchange/22239-num2strexact-exact-version-of-num2str

## 0 Comments