delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/05/19/08:15:49

X-Authentication-Warning: acp3bf.physik.rwth-aachen.de: broeker owned process doing -bs
Date: Fri, 19 May 2000 14:15:30 +0200 (MET DST)
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
X-Sender: broeker AT acp3bf
To: djgpp-workers AT delorie DOT com
Subject: Re: rand() in libc
In-Reply-To: <200005191159.NAA08580@lws256.lu.erisoft.se>
Message-ID: <Pine.LNX.4.10.10005191412130.18991-100000@acp3bf>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Fri, 19 May 2000, Martin Stromberg wrote:

> Ok, how doI  easily say 2^-16, 2^-32 and 2^-48 to the compiler? Is it
> ok to use pow(2, -16) etc. (efficiency)?

No. Use ldexp(), it's usually much more efficient than pow(). If there is
no special support for the operation 'multiply by 2^exponent implemented
in the FP hardware, the library implementor will fall back to using pow(),
but by using ldexp, you're giving him a chance to provide a better method.

In a nutshell, ldexp() is for floating point types what bitshifts are
for integers.

Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019