K
kr
Hi people,
Please contribute to make a good list of tips/methods/suggestions for
writing optimized C code. I think it will be helpful for all of the
programmers community. Please tell your tips/tricks that you feel
should be used to write a code as optimal as the one produced by an
optimizing compiler.
I will start it like this-
1) When we dont need double precision arithmetic, only float
quantities will serve the purpose.
so we should explicitly declare flaot quantities which are double by
default.
float f1;
f1 = f1+2.5f;
instead of--
float f1;
f1 = f1+2.5; // 2.5 is a double quantity here
which leads to double precision arithmatic being done by the processor
and hence a time wastage.
Thanks.
Please contribute to make a good list of tips/methods/suggestions for
writing optimized C code. I think it will be helpful for all of the
programmers community. Please tell your tips/tricks that you feel
should be used to write a code as optimal as the one produced by an
optimizing compiler.
I will start it like this-
1) When we dont need double precision arithmetic, only float
quantities will serve the purpose.
so we should explicitly declare flaot quantities which are double by
default.
float f1;
f1 = f1+2.5f;
instead of--
float f1;
f1 = f1+2.5; // 2.5 is a double quantity here
which leads to double precision arithmatic being done by the processor
and hence a time wastage.
Thanks.