Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: Help with casts Message-ID: <15278@smoke.brl.mil> Date: 21 Feb 91 21:02:14 GMT References: <1991Feb21.040145.8678@cec1.wustl.edu> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 18 In article <1991Feb21.040145.8678@cec1.wustl.edu> abed@saturn.wustl.edu (Abed M. Hammoud) writes: > i.e my question is when I precede a variable by a cast does > that add to the amount of work done during run-time ?. It might or might not, depending. Note that the right way to express what you are contemplating is "applying a cast", or "converting to a different type", i.e. a more active notion of what a cast means. In some circumstances the compiler may have had to perform the conversion anyway, so an explicit conversion might not add any burden. There are also some short cuts that are permitted that in some cases could avoid having to "really" do the indicated conversion. My recommendation is to EITHER explicitly cast only where necessary to meet strict typing requirements, OR explicitly cast in those circumstances and also every place that the compiler would otherwise perform an implicit conversion. The latter policy is rather hard for anyone other than a C "language lawyer" to get right, so your best bet is to keep casts to a minimum. In many cases, if a cast is actually necessary it indicates an improper choice of types has been made somewhere.