Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I wrote my answer in the form of a <a href="http://blog.frama-c.com/index.php?post/2011/11/18/Analyzing-single-precision-floating-point-constants" rel="nofollow">blog post</a></p> <p>To summarize some of the points here: you could interface <code>strtold()</code> and <code>strtof()</code> from OCaml. For the former, you would have to consider how you are going to store the result it produces, since there only is a point if <code>long double</code> is larger than <code>double</code> on your host architecture. There remains the problem that these functions are buggy in one of the most widely used C library. Very slightly buggy, but buggy for exactly the examples that are going to be of interest if you are doing this to study double rounding.</p> <p>Another way is to write your own function, starting from <a href="http://www.exploringbinary.com/correct-decimal-to-floating-point-using-big-integers/" rel="nofollow">another post</a> in the blog you refer to.</p> <p>Finally, the phrase "Even getting single-precision floats right requires me to parse literals with values bigger than 64 bit" that you use in the comments is still a strange way to put it. The intermediate format(s) in which you can parse the representation of a single-precision float before you round it to single-precision <strong>have to</strong> be lossless, otherwise there will be double rounding. Double rounding may be more or less difficult to exhibit depending on the precision of the lossy intermediate format, but using 80 bits or 128 bits binary floating-point formats is not going to remove the problem, just make it more subtle. In the simple algorithm that I recommend, the intermediate format is a fraction of two multiprecision integers.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload