Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I want to calculate with simple double floating point precision.

NestList[#^2 &, 0.5, 50]
=>
 {0.5, 0.25, 0.0625, 0.00390625, 0.0000152588, 2.32831*10^-10, 
 5.42101*10^-20, 2.93874*10^-39, 8.63617*10^-78, 7.45834*10^-155, 
 5.56268464626800*10^-309, 3.09434604738300*10^-617, 
 9.57497746095000*10^-1234, 9.1680193377700*10^-2467, 
 8.4052578577800*10^-4933, 7.0648359655800*10^-9865, 
 4.9911907221000*10^-19729, 2.4911984824000*10^-39457, 
 6.206069878700*10^-78914, 3.851530333900*10^-157827, 
 1.483428591300*10^-315653, 2.20056038500*10^-631306, 
 4.84246601000*10^-1262612, 2.34494770600*10^-2525223, 
 5.4987797400*10^-5050446, 3.0236578700*10^-10100891, 
 9.142506900*10^-20201782, 8.358543200*10^-40403563, 
 6.986524500*10^-80807125, 4.881152400*10^-161614249, 
 2.382564900*10^-323228497, 5.67661600*10^-646456994, 
 3.22239600*10^-1292913987, 1.03838400*10^-2585827973, 
 1.07824100*10^-5171655946, 1.16260000*10^-10343311892, Underflow[], 
 Underflow[], Underflow[], Underflow[], Underflow[], Underflow[], 
 Underflow[], Underflow[], Underflow[], Underflow[], Underflow[], 
 Underflow[], Underflow[], Underflow[], Underflow[]}

But I would really like to get

 {0.5, 0.25, 0.0625, 0.00390625, 0.0000152588, 2.32831*10^-10, 
 5.42101*10^-20, 2.93874*10^-39, 8.63617*10^-78, 7.45834*10^-155, 0, 0, 0, 0 ...}

And I want

 FixedPoint[#^2 &, 0.5]  =>  0.

not

 FixedPoint[#^2 &, 0.5]  =>  Underflow[]
share|improve this question

marked as duplicate by Artes, Oleksandr R., rm -rf Jan 1 at 21:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
you might want to use Chop (use 2nd argument to specify tolerance). –  Pinguin Dirk Jan 1 at 18:33
    
I thought about Chop, but it's ugly and I want the performance of 64bit floats. Besides it doesn't solve another problem I didn't mention: 1 + ReallySmallNumber => Overflow. With Check/Replace it's really the same thing. –  user11523 Jan 1 at 19:10
    
In cases like this one may prefer to use Compile with specified RuntimeOptions to have better control over the numerics environment. In particular you will want "CatchMachineUnderflow" -> False and usually "CompareWithTolerance" -> False as well. –  Oleksandr R. Jan 1 at 20:44