Re: Does Casting Slow a Program Down?
- From: "PeterOut" <MajorSetback@xxxxxxxxxx>
- Date: 31 Jan 2007 07:12:49 -0800
On Jan 31, 10:01 am, Zara <me_z...@xxxxxxxxxxxxxxx> wrote:
If the compiler detectes tha usLimit and iLimit are constants, then it
may detect that (int)usLimit is also constant and it would probably
generate the exact same machine code for both samples.
But this behaviour depends on the optimizations capabilities an
settings of the compiler, and of the code surrounding the snippet you
have shown us.
You may help the compiler declaring either
const unsigned short usLimit=10;
or
const int iLimit=10;
Thanks very much for your fast reply. I was thinking in general
terms. usLimit/iLimit are given a constant value in the example that
I posted but I was thinking in terms of their being variables that are
determined by input data and/or passed as arguments to a function.
Also, what about casting a (single precision) float to a double or
vice versa? Would that impact the run time or would it depend on the
compiler?
Thanks again,
Peter.
.
- Follow-Ups:
- Re: Does Casting Slow a Program Down?
- From: santosh
- Re: Does Casting Slow a Program Down?
- From: Christopher Layne
- Re: Does Casting Slow a Program Down?
- References:
- Does Casting Slow a Program Down?
- From: PeterOut
- Re: Does Casting Slow a Program Down?
- From: Zara
- Does Casting Slow a Program Down?
- Prev by Date: Re: Does Casting Slow a Program Down?
- Next by Date: Re: How to reduce Zero Initialised region.
- Previous by thread: Re: Does Casting Slow a Program Down?
- Next by thread: Re: Does Casting Slow a Program Down?
- Index(es):
Relevant Pages
|