Advertisement

help me yes i'm serious

Started by July 11, 2000 07:53 PM
4 comments, last by Theses 24 years, 5 months ago
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.
-----------------------------1. "Diplomacy is the art of saying 'Nice doggie!'... till you can find a rock." 2. "Always remember you're unique, just like everyone else." 3. "If we don't succeed, we run the risk of failure."-Dan Quayle4. If life gives you sour grapes, squash them and make wine!
Advertisement
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***
There is no difference at all after compilation.

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
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
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.

_______________________________
"To understand the horse you'll find that you're going to be working on yourself. The horse will give you the answers and he will question you to see if you are sure or not."
- Ray Hunt, in Think Harmony With Horses
ALU - SHRDLU - WORDNET - CYC - SWALE - AM - CD - J.M. - K.S. | CAA - BCHA - AQHA - APHA - R.H. - T.D. | 395 - SPS - GORDIE - SCMA - R.M. - G.R. - V.C. - C.F.

This topic is closed to new replies.

Advertisement