Representation of floats



It is not "returning exact values".  It is *printing *a rounded value.

To demonstrate this to yourself, try:

     document.getElementById("p").innerHTML+=6.3999999999999997E-5;

            -s


2012/5/16 Evgeniy Maevskiy <emaevskiy at e-math.ru>

> I'm sorry, but I have to try again. Let us compare.
>
> Maxima 5.27.0
> ----------------
>
> numer:true$
> for k:1 thru 29 do print("k=",k,":  ",1/5^k)$
>
> k= 1 :   0.2
> k= 2 :   0.04
> k= 3 :   0.008
> k= 4 :   0.0016
> k= 5 :   3.2000000000000003E-4
> k= 6 :   6.3999999999999997E-5
> k= 7 :   1.2799999999999999E-5
> k= 8 :   2.5600000000000001E-6
> k= 9 :   5.1200000000000003E-7
> k= 10 :   1.024E-7
> k= 11 :   2.0479999999999999E-8
> k= 12 :   4.0959999999999999E-9
> k= 13 :   8.1920000000000002E-10
> k= 14 :   1.6384E-10
> k= 15 :   3.2768000000000003E-11
> k= 16 :   6.5535999999999999E-12
> k= 17 :   1.3107200000000001E-12
> k= 18 :   2.6214400000000002E-13
> k= 19 :   5.2428799999999999E-14
> k= 20 :   1.0485759999999999E-14
> k= 21 :   2.0971519999999998E-15
> k= 22 :   4.1943040000000002E-16
> k= 23 :   8.3886080000000009E-17
> k= 24 :   1.6777216000000002E-17
> k= 25 :   3.3554432000000005E-18
> k= 26 :   6.7108864000000012E-19
> k= 27 :   1.3421772800000001E-19
> k= 28 :   2.6843545600000002E-20
> k= 29 :   5.3687091200000004E-21
>
>
> Firefox 11.0
> ------------
>
> <html>
> <body>
> <p id="p"></p>
> <script>
> for(k=1;k<30;k++)
> document.getElementById("p").innerHTML+="k="+k+":
>  "+1/Math.pow(5,k)+"<br>";
> </script>
> </body>
> </html>
>
> k=1: 0.2
> k=2: 0.04
> k=3: 0.008
> k=4: 0.0016
> k=5: 0.00032
> k=6: 0.000064
> k=7: 0.0000128
> k=8: 0.00000256
> k=9: 5.12e-7
> k=10: 1.024e-7
> k=11: 2.048e-8
> k=12: 4.096e-9
> k=13: 8.192e-10
> k=14: 1.6384e-10
> k=15: 3.2768e-11
> k=16: 6.5536e-12
> k=17: 1.31072e-12
> k=18: 2.62144e-13
> k=19: 5.24288e-14
> k=20: 1.048576e-14
> k=21: 2.097152e-15
> k=22: 4.194304e-16
> k=23: 8.388608000000001e-17
> k=24: 1.6777216000000002e-17
> k=25: 3.3554431999999997e-18
> k=26: 6.710886399999999e-19
> k=27: 1.34217728e-19
> k=28: 2.6843545600000002e-20
> k=29: 5.3687091200000004e-21
>
> =================================
>
> I don't see: where is rounding? Firefox up to k=22 returns exact values
>
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>