Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

zero vs 0
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.


Report this thread to moderator Post Follow-up to this message
Old Post
strellnikof
10-09-06 12:56 PM


Re: zero vs 0
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 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.

Report this thread to moderator Post Follow-up to this message
Old Post
Binyamin Dissen
10-12-06 11:55 PM


Re: zero vs 0
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.


Report this thread to moderator Post Follow-up to this message
Old Post
Richard
10-12-06 11:55 PM


Re: zero vs 0
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 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.
>



Report this thread to moderator Post Follow-up to this message
Old Post
William M. Klein
10-12-06 11:55 PM


Re: zero vs 0
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

Report this thread to moderator Post Follow-up to this message
Old Post
Donald Tees
10-12-06 11:55 PM


Re: zero vs 0
> 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






Report this thread to moderator Post Follow-up to this message
Old Post
Michael Mattias
10-12-06 11:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:54 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.