Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: Portability of floor(log(N))

by syphilis (Archbishop)
on Mar 13, 2018 at 00:47 UTC ( [id://1210780]=note: print w/replies, xml ) Need Help??


in reply to Re: Portability of floor(log(N))
in thread Portability of floor(log(N))

I'd probably recommend %a

Good advice - and the value I'd be looking at is $num itself.
Perl is notorious for assigning values incorrectly - and I have a number of -Duselongdouble builds of perl (Windows and Linux) which assign the value 1e-33 incorrectly as 0xa.6274bbdd0fadd61p-113, instead of (correctly) 0xa.6274bbdd0fadd62p-113.
This doesn't cause any test failures for me. It underestimates the value of '1e-33' by a measly 1 ULP, and I think we're looking for an overestimate for the test to fail.
(I also don't discount the possibility that the error is in the calculation.)

If the problem *is* in the value that perl assigns for '1e-33' then your solution is to make sure that a correct value is being assigned - for which you can use Math::MPFR or (I believe) Data::Float. There are perhaps other modules, too.
Data::Float is pure perl and therefore makes for a more straightforward installation. I use Math::MPFR, which requires the MPFR C library.

Afterthought: IIRC, some systems that implement the 'long double' type don't actually implement the full range of math functions for the long double.
It's therefore worth determining whether the underlying libc for those 2 FAIL reports provides floorl() and logl(), or whether libc just uses the double precision floor() and log() functions.

Cheers,
Rob

Replies are listed 'Best First'.
Re^3: Portability of floor(log(N))
by toolic (Bishop) on Mar 13, 2018 at 14:48 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1210780]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found