Yo All!

Mark asked me to dig deeper.

On Sun, 9 Apr 2017 19:06:53 -0700
"Gary E. Miller" <[email protected]> wrote:

> > Comparing against LOGTOD(-31) will fail for any value less than
> > ~0.2ns (the minimum l_fp fraction).  
> 
> Yup.  Except the results is a constant, and having to compute a log
> every time on a constant is a bit watesful.


So I made a test:

    #include <math.h>
    #define LOGTOD(a)   ldexp(1., (int)(a)) /* log2 to double */
    int main( int argc, char ** argv)
    {
        return (int)LOGTOD(1e-9);
    }

gcc -g test.c -o test
gdb test
disasssemble main:

    Dump of assembler code for function main:
       0x00000000004004b6 <+0>: push   %rbp
       0x00000000004004b7 <+1>: mov    %rsp,%rbp
       0x00000000004004ba <+4>: mov    %edi,-0x4(%rbp)
       0x00000000004004bd <+7>: mov    %rsi,-0x10(%rbp)
       0x00000000004004c1 <+11>:        mov    $0x1,%eax
       0x00000000004004c6 <+16>:        pop    %rbp
       0x00000000004004c7 <+17>:        retq   
    End of assembler dump.

So  I'm shocked, gcc made LOGTOD(1e-9) a simple binary constant.

RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
        [email protected]  Tel:+1 541 382 8588

            Veritas liberabit vos. -- Quid est veritas?
    "If you can’t measure it, you can’t improve it." - Lord Kelvin

Attachment: pgpNYwy2Ntx5c.pgp
Description: OpenPGP digital signature

_______________________________________________
devel mailing list
[email protected]
http://lists.ntpsec.org/mailman/listinfo/devel

Reply via email to