Subject:
|
Re: floating point operation
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Wed, 28 Nov 2001 20:38:44 GMT
|
Viewed:
|
1497 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
|
|
|
|