To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 2142
2141  |  2143
Subject: 
Re: floating point operation
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Wed, 28 Nov 2001 20:38:44 GMT
Viewed: 
1401 times
  
Dennis Diehl <dennis@mathematik.uni-freiburg.de> wrote:
What is the reason for this difference?

Compiler optimization?  At least, a disassembly of similar code showed me
that that seemed to be the case.

The compiler can see that t is not used.  Try returning t, or copying t to
a global before you return from main.  That will make things closer I
think, but of course the first version will still run faster in the end.

-Kekoa



Message has 1 Reply:
  Re: floating point operation
 
(...) I should clarify that this is true for the first version only. For some reason, the compiler does not optimize the second version in the same way. Anyways, what I see in the disassembly for the first version is a loop to 100 inside a loop to (...) (23 years ago, 28-Nov-01, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  floating point operation
 
I did some experiments with floating point operations and I was surprised when I tried this: int main(){ long t1; int i,j; float t; t1 = sys_time; for(j=0; j<1000; j++){ t=0.06; for(i=0; i<100; i++){ t=1.7*t; } } lcd_int((sys_time - t1)/1000); (...) (23 years ago, 28-Nov-01, to lugnet.robotics.rcx.legos)

4 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR