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 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: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 Precedence: bulk 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.