delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/05/09:41:17

Message-Id: <3.0.5.32.19980304221028.007bc100@math.amu.edu.pl>
Date: Wed, 04 Mar 1998 22:10:28 +0100
To: Bum-Seok Hyun <dominic AT gong DOT snu DOT ac DOT kr>, djgpp AT delorie DOT com
From: Maciej Radziejewski <maciejr AT math DOT amu DOT edu DOT pl>
Subject: Re: [Q]Computing speed in C++
In-Reply-To: <34FD3174.2401F904@gong.snu.ac.kr>
References: <34FCB769 DOT 42BEF1A8 AT gong DOT snu DOT ac DOT kr>
Mime-Version: 1.0

At 19:48 1998.03.04 +0900, Bum-Seok Hyun wrote:
>(...)
>
>Main body of my test code is
>
>for(int i=1 ; i<10001 ; i++)
>   for(int j=1 ; j<10001 ; j++)
>       for(int k=1 ; k < 11 ;  k++)  sum += i;
>
>Above code is ,of course , for C++.
>
>In C code, I just moved variable definitions
>into the first line of the code.
>Like,
>
>int i,j,k;
>float sum;
>
>(...)
>

Perhaps you could try changing the last assignment to
    sum += j;
and making j vary from -5000 to <5001 ?
This way you won't get out of int range
(I assume sum is initialized to 0);
I don't think this is the problem, though.

On my system (PGCC, EGCS 1.0.1 :-)
there were no significant differences between C, C++
and C++ with declarations inside for
(about 49s in each case).

Maciej.

- Raw text -


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