FYI...
# dwhite@nist.gov 3/23/04 - based on BASIC code # in "Astronomical Algorithms" 2nd ed. by Jean Meeus, # pg 17-19 # start of code block 1 $x = 1 ; $j = 0 ; $x *= 2 ; print "Testing significant bits, significant digits...\n"; while (($x + 1) != $x) { print "\t$j\t$x\n"; $j++ ; $x *= 2 ; } print "\t$j\t$x\n"; print "\n", $j , " significant bits in mantissa of floating number\n" +, int($j * 0.30103) , " significant digits in a decimal number (", $j + * 0.30103 , ")\n above is only for SIMPLE ARITHMETICS, not trig func +tions!\n"; # end of code block 1 print "\nthe 2nd column here should NOT list diverging numbers...\n"; print "\$x=1.0/3.0; for(\$j=1;\$j<31;\$j++) { \$x = (9*\$x+1)*\$x-1 ; }\n"; # start of code block 2 $x = 1.0/3.0 ; for($j=1;$j<31;$j++) { $x = (9*$x+1)*$x-1 ; # print "$j\t$x\n"; # for details if ($j % 6 == 1) { print "$j\t$x\n"; } } print "However, they probably will diverge on your machine.\n"; # end of code block 2

In reply to Re: Floating point (in)accuracy: more "interesting" than expected by dwhite20899
in thread Floating point (in)accuracy: more "interesting" than expected by graff

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.