in reply to Re^3: Need more precision.
in thread Need more precision.

Okay. I'll bite.

Are you suggesting that I use 2 of salva's 128-bit integers to implement my own fixed-point math?

Or are you suggesting that there is some way to use single 128-bit integers to store both a 64-bit precision and the fixed point mantissa; and have the existing 128-bit integer operations sort out he fixed-point stuff for me?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Replies are listed 'Best First'.
Re^5: Need more precision.
by Anonymous Monk on Jun 09, 2015 at 22:53 UTC

    I was initially thinking the former... I'm a little confused about the latter suggestion, since I'm not sure integer operations would "sort out" floating point stuff, one would still have to implement some of the operations oneself, so it sounds like implementing a custom 128-bit floating point type...?

    Still doing a bit of research myself out of curiosity, so no perfect answers yet, but what about something like https://software.intel.com/en-us/articles/intel-decimal-floating-point-math-library - apparently up to 34 decimal digits in 128 bits?

      I'm a little confused about the latter suggestion, since I'm not sure integer operations would "sort out" floating point stuff,

      That's my understanding also; but I was hoping ... :)

      I have native 64-bit ints; so combining two of those to give me fixed point would give huge precision; no need to move to two 128-bit integers.

      But I'm fuzzy on the implementation of fixed point floats using two ints. If you come across any pointers/notes/implementations I'd love to hear of it.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
      In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

        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 :-)