Help with casts
Stanley Friesen
sarima at tdatirv.UUCP
Sat Feb 23 06:48:17 AEST 1991
In article <409 at ceco.ceco.com> garry at ceco.ceco.com (Garry Garrett) writes:
>> I am new to C, and I have been a couple of times encountering
>> the term lvalue...I looked it up in K&R C book but I still don't
>> get it...
The official definition (from the ANSI standard) is essentially that an
lvalue is an expression that refers to an object in memory (as opposed
to an expression that generates a value). If find this quite simple.
>> I also have another small question, please take a look at
>> the two loops below and tell me if there is any difference
>> in speed.
>> for (i=0; i < 100; i++)
>> x += i;
>> As compared to...
>> for (i=0; i < 100; i++)
>> x += (float)i;
On any reasonable compiler these will be identical. Assuming that 'x' is of
type float the assignment generates an *implicit* conversion to float, which
is merely made explicit by the cast. There is no other semantic difference.
[Now if 'x' were of type int...]
--
---------------
uunet!tdatirv!sarima (Stanley Friesen)
More information about the Comp.lang.c
mailing list