www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/02/27/12:49:03

From: kurt DOT skauen AT funcom DOT com (Kurt Skauen)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: some advice required
Date: Thu, 27 Feb 1997 16:43:41 GMT
Organization: Funcom production A/S
Lines: 33
Message-ID: <857061715.836060@araga.funcom.com>
References: <c=GB%a=_%p=Indigo_Active_Vi%l=CRIANLARICH-970227150111Z-238 AT crianlarich DOT Indigo>
Reply-To: kurt DOT skauen AT funcom DOT com
NNTP-Posting-Host: araga.funcom.com
Cache-Post-Path: araga.funcom.com!unknown AT pcshare44 DOT funcom DOT com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Robert Humphris <r DOT humphris AT indigo-avs DOT com> wrote:

>I think that they are both the same! The speed ups with maths occur at
>multiplicaton/division time
>when you do the old bit shifts (<< & >>) instead.
>
>If this is wrong, will some one please tell me, as I don't want to be
>labouring upder misinformation
>
>Rob Humphris

This is normaly not true when programming in C, or C++ since most
compiler will optimize all division/multiplication with constants that
is a power of two to shift's anyway so 

foo = bar / k;

where bar is variable integer, and k is a constant which is a power of
two will be converted into:

foo = bar >> log(k) / log(2);

So using shiftings for the sake of optimaization is normaly wasted,
and often leads to less self-explaining code.


=/=\=/=\=/=\=/=\=/=\=/=\=/=\=/=\=/=\=/=\=/=\=/=\=/=\=

How to kill a daemon:  for(;0;)

Kurt. 	Programmer Funcom/R&D
The above expressions is not ment to represent Funcom.

- Raw text -


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