Code Comments
Programming Forum and web based access to our favorite programming groups.when working with numeric data isn't it more effecient to use 0 (or +0 depending on whether the data item is signed) instead of the word zero? I always thought a conversion took place when using the word zero and that unusual things could happen when using zero.
Post Follow-up to this messageOn 9 Oct 2006 07:06:23 -0700 "strellnikof" <bprice@humana.com> wrote: :>when working with numeric data isn't it more effecient to use 0 (or +0 :>depending on whether the data item is signed) instead of the word zero? :> I always thought a conversion took place when using the word zero and :>that unusual things could happen when using zero. Any compiler worth its salt should pre-convert the literal to a form matchin g the comperand. -- Binyamin Dissen <bdissen@dissensoftware.com> http://www.dissensoftware.com Director, Dissen Software, Bar & Grill - Israel Should you use the mailblocks package and expect a response from me, you should preauthorize the dissensoftware.com domain. I very rarely bother responding to challenge/response systems, especially those from irresponsible companies.
Post Follow-up to this messagestrellnikof wrote: > when working with numeric data isn't it more effecient to use 0 (or +0 > depending on whether the data item is signed) instead of the word zero? > I always thought a conversion took place when using the word zero and > that unusual things could happen when using zero. Do you think that the compiler outputs machine code with the 4 letters 'ZERO' and sufficient code to recognise that and convert it to an appropriate zero value at run time ? The answer is no it doesn't. The compiler recognises ZERO or 0 or +0 and generates the same machine code whichever one is used. Whether the compiler itself takes a few less or more machine cycles is: a) dependant on how the compiler is written. b) irrelevant.
Post Follow-up to this messageAs others have indicated, in GENERAL, this is not true. I *do* believe that the "zero sign test" is (for SOME implementations) less efficient that a test for a zero value, i.e. 05 Num-Field Pic 99999 (comp-whatever) If Num-Field Zero (sign test) is less efficient than If Num-Field = Zero (or 0) (relational test) may be more efficient However, unless this were in a VERY tight (frequently performed) loop, I dou bt any run-time would ever be able to tell the difference. Also, you would nee d to check your specific compiler -as the generated code may or MAY NOT be differ ent for the two types of source code. -- Bill Klein wmklein <at> ix.netcom.com "strellnikof" <bprice@humana.com> wrote in message news:1160402783.207211.9330@h48g2000cwc.googlegroups.com... > when working with numeric data isn't it more effecient to use 0 (or +0 > depending on whether the data item is signed) instead of the word zero? > I always thought a conversion took place when using the word zero and > that unusual things could happen when using zero. >
Post Follow-up to this messagestrellnikof wrote: > when working with numeric data isn't it more effecient to use 0 (or +0 > depending on whether the data item is signed) instead of the word zero? > I always thought a conversion took place when using the word zero and > that unusual things could happen when using zero. > you mean in code? Once compiled, what difference could there be? Donald
Post Follow-up to this message> strellnikof wrote: > > you mean in code? Once compiled, what difference could there be? If you are worried about 'efficiency' differences between "Zero," "0" and "+0" in your source code, you have seriously misplaced priorities. Like, first you should focus on learning what "compilation" means. MCM
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.