My current approach is to think about it in two steps: First, if 128-bit ints are not supported natively, one needs routines to handle normal arithmetic operations on those (so you don't need to worry whether they are 2x 64-bit ints or even 4x 32-bit ints). That shouldn't be too difficult (it'd be the same basic idea as doing 16-bit math on an 8-bit uC), plus there seem to be a couple of libraries out there. E.g. Boost apparently has a int128_t and bigger (http://www.boost.org/doc/libs/1_53_0/libs/multiprecision/doc/html/boost_multiprecision/tut/ints/cpp_int.html)... Math::Int128 apparently tries to use the native 128-bit ints, which as far as I understand from what I've read so far are not "officially" supported by MS, which would be my guess as to why the module has some CPAN Testers failures on Windows.

Second, use those routines to implement the fixed-point stuff. Addition and subtraction is pretty trivial; multiplication would either require a temporary 256-bit integer or some rounding; still doing research on the latter... you've piqued my curiosity :-)


In reply to Re^7: Need more precision. by Anonymous Monk
in thread Need more precision. by BrowserUk

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.