Go to Post Social life? Ha! Robotics is my social life. :D - Éowyn [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Spotlight this post!  
Unread 07-12-2006, 23:19
TubaMorg TubaMorg is offline
Programmermechanicalelect ricalcoach
AKA: Dan
FRC #1480 (Robatos Locos)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Houston
Posts: 450
TubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond repute
Re: incrementing

i++ is shorthand for i = i + 1 since incrementing by one is such a common task in programming. Similarly i-- is the same as i = i -1. If you want to add or subtract something different then you have to use the long version as in i = i + 3.


Not many people realize you can also go ++i and --i which is subtly different. In most cases the end effect is the same but not always. With ++i (prefixed) the value is computed before the expression is evaluated. The postfix version i++ is the opposite where the value is computed AFTER the expression is evaluated. This doesn't make any difference if you just go:

i++;
or
++i;

However if you try:

m = ((++i)*(j++)/5;

i will increment by 1 BEFORE the rest of the expression is evaluated. j will be incremented AFTER the expression is evaluated.

Good luck!
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 20:43.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi