in reply to Re^2: XS, C doubles and -Duselongdouble
in thread XS, C doubles and -Duselongdouble

It's just a matter of finding the position of the least significant (set) bit

It's probably quicker to just test that there are no bits set in the lowest 8 bits (64-52) of the mantissa. Those 8 bits are stored in the last (10th) byte of the real*10 representation. So it should just be a case of (assuming you have the 10 bytes packed in scalar)

if( substr $packedReal10, -1 ) { warn 'Loss of precision...'; }
any Microsoft compiler that knows about long doubles will tell you that sizeof(long double) == sizeof(double) == 8.

Gah. How stupid is that. You know, I have a funny feeling that I saw a set of 80bit real math functions kicking around inside one of the system DLLs. In theory, it would be possible to wrap a header file and an import library around that and get access to them from C/C++. I can't remember where I (think) I saw them and a quick grep didn't locate them. I'll have another look later.


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".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^4: XS, C doubles and -Duselongdouble
by syphilis (Archbishop) on Jun 10, 2007 at 15:35 UTC
    Gah. How stupid is that.

    Stupidity is hard to quantify ... so I'm therefore relieved that the question was rhetorical :-)
    I was recently directed to http://blogs.msdn.com/ericflee/archive/2004/06/10/152852.aspx ... which I found to be rather interesting, somewhat amusing, and a little disturbing.

    Cheers,
    Rob
      I found to be rather interesting, somewhat amusing, and a little disturbing.

      Indeed. One of the comments suggests that the mapping of real10 to real8 is done "(to cheat on benchmarks)", but I am under the impression that the (Intel) floating point processor does all it computations in 80-bits, even if the results are truncated when they are stored to ram.

      If that's the case, and I am pretty sure that I read that on a reliable source which I will attempt to relocate, then there would be no performance advantage in not storing the 80-bits after the computation?


      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".
      In the absence of evidence, opinion is indistinguishable from prejudice.