Home > Archive > Cobol > October 2006 > zero vs 0
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| strellnikof 2006-10-09, 7:56 am |
| 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.
| |
| Binyamin Dissen 2006-10-12, 6:55 pm |
| On 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 matching
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.
| |
| Richard 2006-10-12, 6:55 pm |
|
strellnikof 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.
| |
| William M. Klein 2006-10-12, 6:55 pm |
| As 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 doubt
any run-time would ever be able to tell the difference. Also, you would need to
check your specific compiler -as the generated code may or MAY NOT be different
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.
>
| |
| Donald Tees 2006-10-12, 6:55 pm |
| strellnikof 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
| |
| Michael Mattias 2006-10-12, 6:55 pm |
| > 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
|
|
|
|
|