develooper Front page | perl.perl5.porters | Postings from August 2010

Re: PATCH: srand returns the seed

Thread Previous | Thread Next
Andy Dougherty
August 3, 2010 06:26
Re: PATCH: srand returns the seed
Message ID:
On Mon, 2 Aug 2010, Bo Lindbergh wrote:

> Nicholas Clark wrote:
> > What I can't work out is whether there is any shortcut way in ANSI C to find
> > out whether a value is -0, distinct from 0, short of *printf().
> As long as the compiler is sufficiently C99-like:
>     fpclassify(value)==FP_ZERO && signbit(value)

Yes, both copysign() and signbit() are widely available.  The challenge 
arises in that perl tries to rely only on C89-like behavior, since not all 
compilers support the C99 standard.  To help provide appropriate warnings 
to developers who use gcc, we often add -ansi to gcc's flags, which 
effectively hides things like signbit().

In ANSI C, if signbit() isn't available, the only other thing I can think 
of doing is to assume IEEE-754 and explicitly check the correct bit some 
way or another.  

    Andrew Dougherty

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About