help me yes i'm serious
is there any difference between
glColor3f(1, 1, 1)
glColor3f(1.0f, 1.0f, 1.0f)
glColor3f(1.0, 1.0, 1.0)
No, it makes almost no difference here. The fastest (very small difference) would be 1.0f because it stops at one decimal point, and isn''t an integer, I think.
thay all have the same speed at run time since they''re all compiled to the smae code
but 1.0f will be 0.01 miliseconds faster when you compile the code ----> no difference
----------------
- Pouya / FOO!!!
***CENSORED***
but 1.0f will be 0.01 miliseconds faster when you compile the code ----> no difference
----------------
- Pouya / FOO!!!
***CENSORED***
There is no difference at all after compilation.
Throwing them in some VC++ application, here is what comes out in the assembling listing.
Mike Roberts
aka milo
mlbobs@telocity.com
Throwing them in some VC++ application, here is what comes out in the assembling listing.
; 1211 :glColor3f(1, 1, 1); push 1065353216 ; 3f800000H push 1065353216 ; 3f800000H push 1065353216 ; 3f800000H call DWORD PTR __imp__glColor3f@12; 1212 :glColor3f(1.0f, 1.0f, 1.0f); push 1065353216 ; 3f800000H push 1065353216 ; 3f800000H push 1065353216 ; 3f800000H call DWORD PTR __imp__glColor3f@12; 1213 :glColor3f(1.0, 1.0, 1.0); push 1065353216 ; 3f800000H push 1065353216 ; 3f800000H push 1065353216 ; 3f800000H call DWORD PTR __imp__glColor3f@12
Mike Roberts
aka milo
mlbobs@telocity.com
Really?
That's not how its suppose to work
1 would be a constant signed integer value of 1
1.0f forces it to be a floating point value
1.0 defaults to a double
It is an obvious compiler optimization to not convert the numbers at run-time. You can avoid warning at least by telling the compiler you want floats
Edited by - Magmai Kai Holmlor on July 11, 2000 11:23:32 PM
That's not how its suppose to work
1 would be a constant signed integer value of 1
1.0f forces it to be a floating point value
1.0 defaults to a double
It is an obvious compiler optimization to not convert the numbers at run-time. You can avoid warning at least by telling the compiler you want floats
Edited by - Magmai Kai Holmlor on July 11, 2000 11:23:32 PM
I believe it is standard C philosophy that any expressions which can be evaluated at compile time vs. run time are evaluated at compile time.
If they were evaluated at run time the output of your program would be exactly the same. You program would be doing the exact same work the compiler could have done at compile time. Only difference is, by doing it at compile time, your program is more compact, and more importantly, faster.
If they were evaluated at run time the output of your program would be exactly the same. You program would be doing the exact same work the compiler could have done at compile time. Only difference is, by doing it at compile time, your program is more compact, and more importantly, faster.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement