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

RE: [perl #76756] PATCH: srand returns the seed

Thread Previous | Thread Next
From:
Jan Dubois
Date:
August 2, 2010 11:12
Subject:
RE: [perl #76756] PATCH: srand returns the seed
Message ID:
037401cb326e$4f6e2140$ee4a63c0$@activestate.com
On Mon, 02 Aug 2010, 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().

In ASNI C99 you can use copysign(), but that is not required in C89.  It has been
an IEEE 754 recommended function, so it is present in many older libraries.

The only other way I can think of is computing 1/x and checking if you get
-Inf or Inf, but that may be a costly operation, given that it will throw
a floating point exception.

Cheers,
-Jan


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About