Code: Select all
glVertex3f(1.0f, 0.0f, 0.0f);
Moderator: Coders of Rage
Code: Select all
glVertex3f(1.0f, 0.0f, 0.0f);
You are explicitly telling the compiler to treat the numerical constants as floats.Bullet Pulse wrote:I just started learning OpenGL and I want to know what f means in the example below.Code: Select all
glVertex3f(1.0f, 0.0f, 0.0f);
OoOo, great way to illustrate that!avansc wrote:try this out.
printf("%d\n", sizeof(1.0));
printf("%d\n", sizeof(1.0f));
by default C will cast any decimal number to a double, the f tells it to cast to float just like falco said.
and the f that is appended on the gl call indicates it takes floats.
Well that's because the floating point coprocessor (IIRC) has the same word size as a the normal processor. Also, 32 bit floats hold a lot more information than 32 bit integers. Look up how floating point works if you're interested.Randi wrote:It seems weird to me that a float takes up the same amount of space as a regular int.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Code: Select all
<iframe src="http://gamercard.xbox.com/mgold07.card" scrolling="no" frameBorder="0" height="140" width="204">mgold07.</iframe>
Code: Select all
FLT_MAX=340282346638528859811704183484516925440.0000......
FLT_MIN=0.0000000000000000000000000000000000000117549435082228750796873653722224567781866555677208752150875170627841725945472717285156250000.....
what do you mean standard form?thejahooli wrote:Don't floating points act like standard form which is the reason they can hold large numbers but can't be precise.
I don't actually know this as a fact but it seems like a reasonable idea.
floating point is basically a form of scientific notation. The "mantissa" (IIRC, correct me if I'm wrong) contains a fixed-point fractional number. The "exponent" part is x in a * 10^x, where a is the mantissa. There's other stuff too, like information about sign, but that's the general jist of floating point.short wrote:what do you mean standard form?thejahooli wrote:Don't floating points act like standard form which is the reason they can hold large numbers but can't be precise.
I don't actually know this as a fact but it seems like a reasonable idea.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
by standard form does he mean scientific notation? That's what I was asking.Ginto8 wrote:floating point is basically a form of scientific notation. The "mantissa" (IIRC, correct me if I'm wrong) contains a fixed-point fractional number. The "exponent" part is x in a * 10^x, where a is the mantissa. There's other stuff too, like information about sign, but that's the general jist of floating point.short wrote:what do you mean standard form?thejahooli wrote:Don't floating points act like standard form which is the reason they can hold large numbers but can't be precise.
I don't actually know this as a fact but it seems like a reasonable idea.
I believe so. At least that's what this says: http://www.mathsrevision.net/gcse/pages.php?page=43short wrote:by standard form does he mean scientific notation? That's what I was asking.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Almost, but the exponent is 2 ^ x, not 10 ^ x. Basically the first block of bits (called the mantissa) is a fixed point number x which is -1 <= x < 1, and the next block (the exponent) is a (usually signed) integer which determines the power of 2 to multiply by.Ginto8 wrote:floating point is basically a form of scientific notation. The "mantissa" (IIRC, correct me if I'm wrong) contains a fixed-point fractional number. The "exponent" part is x in a * 10^x, where a is the mantissa. There's other stuff too, like information about sign, but that's the general jist of floating point.short wrote:what do you mean standard form?thejahooli wrote:Don't floating points act like standard form which is the reason they can hold large numbers but can't be precise.
I don't actually know this as a fact but it seems like a reasonable idea.