Difference between Pre and Post Incrementing a variable

I have a problem understanding the nuances between i++ and ++i.
I have run several loops and changed the position of the "++". I noticed that sometimes the out put differs and sometimes the output remains the same.
Is there a rule of thumb as to whether a variable show be post or pre incremented?
Thanks

Thank you all.
After I asked the question, I did a little research and found this (from JGuru shortcourse):
Note that x++ and ++x are equivalent in standalone contexts where the only task is to increment a variable by one,that is, contexts where the ultimate evaluation is ignored:
int x = 4;
x++; // same effect as ++x
System.out.println("x = " + x);
This code produces the output:
x = 5;
The next part after this is:
In the following context, the placement of the increment operator is important:
int x = 4;
int y = x++;
int z = ++x;
System.out.println(
"x = " + x + " y = " + y + " z = " + z);
This code produces the output:
x = 6 y = 4 z = 6
======================================================================
I thought the out put would be x = 4, y = 6, z = 4.
I totally lost! How do I interpet this correctly?

Similar Messages

  • Telling the difference between recalled and post-recall charging adapter.

    I bough an OEM charging adapter on Ebay. Great price, but I'm worried it's just the older one with a green dot painted on.
    The reason I think that is that I noticed the the two prongs on the recalled adapter are straight, whereas the post-recall ones are tapered at the ends.
    This one has a green dot that looks like it was dabbed on and the two prongs are straight.
    Is there any other way to distinguish between the two? Such as a model number or anything?
    Thanks in advance for your help.
    Simon.

    Well, I was worried because the dot can easily be faked. I guess a better question would be do all older adapters have straight squared prongs and all new adapters have tapered prongs? Because mine has a faint green dot with a painted on appearance and squared prongs. I just want to make sure I didn't pay for a forgery that could potentially become a shock/fire hazard. Again, it was purchased on eBay.
    Thanks,
    Simon.

  • Pre and Post for Sends..Confusion?

    Dudes...am I crazy?
    I have 2 tracks. One plays a vocal and one plays a guitar. Both are sent to the same Aux or Bus track with a reverb on it, via the sends on their respective channels.
    If I solo the guitar track, I still get reverb tails from the vocal track on the bus channel as well as the guitar!
    If I switch the vocal track send to "post", then the reverb tails go away for the vocal. By the way, I'm soloing from the mixer channels, not the arrange window.
    Now I understand that if it were the vocal track that I had soloed then switching between Pre and Post on the send would dictate if I hear the reverb tails or not for the vocal track.
    But that's not the track I have soloed! I have the guitar track soloed. So why would I hear reverb tails on a track that's not soloed. And why would the reverb tail go away on the vocal track if I change the send to Post, when that's not the channel I have soloed.
    Am I crazy, or should logic know that if I have a track soloed, it should not play anything else but what's on that track? Regardless of switching from pre to post, if the vocal track is not the track that's soloed, why am I hearing anything from that track at all? I shouldn't have to mute the vocal track or switch it's send from pre to post, just to hear the soloed guitar track by itsself.
    Thanks
    Noah
    G4 Dual 1.42   Mac OS X (10.4.6)   2 UAD Cards/Dynaudio/Martin/U47

    You say you love Logic's "pre/post mute send solo safe function". Sounds like quite a function Does that mean it's changeable in Logic? You make it sound like it's an option.
    By the way, I understand that if you solo a track, it might be cool to also hear it's effects channel without having to solo the bus track its feeding.
    But why would I hear another tracks effects? This only happens when two different tracks have the same bus inserted in their sends. Just because I'm using the same send for two different tracks, doesn't mean I want to hear both sends even if only one track is soloed. That's the part that makes no sense for me. Solo should only address and isolate the track that's soloed and whatever else is related to it (ie...busses/sends/plugs etc..)
    I dunno, I guess when you solo a track it keeps open the bus/send it's using unless your exercise the pre/post send option. And if there's someting else using that bus send as well, it must need to stay open for it too.
    By the way, for me sometimes Logic will continue to play a certain audio track, usually a single track of it's choosing, even if another track is the only one soloed. There are no busses, no plugs, no sends on it, just a straight track and I still have to mute it after soloing some other track. Now that's not right...pre/post etc...is not in the equasion here, can someone explain that?
    Thanks for the help.

  • Difference between doc date,posting date and invoice date

    hi bw guys
    can someone give a brief on the difference between doc date,posting date and invoice date.and the invidual definitions
    thank you

    Hi,
    Posting Date: Date which is used when entering the document in Financial Accounting or Controlling. The posting date can differ from both the entry date and the doc date.
    Document Date: The document date is the date on which the original document was issued. Ex: Inv date, Bill date etc.,
    Invoice Date : Usually the date when goods are shipped. Payment dates are set relative to the invoice date.
    -Vikram

  • Difference between Pre-Calculated Queries in BI 7.0 and BW 3.5

    Hi
    Can somebody tell me the difference between pre-calculated queries (web templates) in BI 7.0 and BW 3.5? Is there any difference in Reporting Agent functionality in creating or scheduling the queries?
    Thanks in advance.

    hi kashi
    u could have searched forum with u r question
    anyway go thru following links
    <b>/community [original link is broken]
    Difference in Delta between BW 3.5 and BI 7.0
    /message/2927917#2927917 [original link is broken]
    How much difference between BW 3.5 and BI 7.0?

  • What are the differences between attributes and variables?

    I am trying to develop a firmer understanding of the difference between attributes and variables. I understand attributes are lexically scoped to a class and variables are lexically scoped to the enclosing block. The lifetime of an attribute is linked to a class' instance. What is the lifetime of a variable? What is the lifetime of variables declared in a script file's top-level?

    It depend on whether the script is running in standalone mode or been called by others (library mode).
    If running as standalone, the variable of the script in the top level exists until the the script exit. If run as library mode, the variable in the top level of the script will never get to execute. Only the function and class available for call.
    Try calling another script with top level variable (place print statement to verify), you realize in library mode, it will never been called. That's why the main method as in Java is never needed because of this reason.

  • Posting of difference between PO and invoice by authorization level

    Hi all,
    I have a question on price difference between PO and invoice. 
    If i want to restrict postings of invoice by authorization like the following, is it possible to be done?  If yes, how?
    Clerks only allowed to post those invoice with no difference and rounding difference (small difference).  Other invoice with difference (not caused by rounding) can be posted by a higher authorised person and not the clerk.  Can this type of authorization be set? 
    Thanks.
    Regards,

    Hello
    First decide on the authorization roles for different users.
    Then these roles can be set by the BASIS team.
    Also tolerence groups for different users and amounts can also be set.
    Tolerances for Employees
    To carry out the activity, choose one of the following navigation options:
    Transaction Code     SPRO
    IMG Menu     Financial Accounting ® Accounts Payable Accounts Receivable  ® Business Transactions ® Incoming Payments  ® Manual incoming payments ® Define Tolerance Groups for Employees
    Tolerances for Business Partners
    To carry out the activity, choose one of the following navigation options:
    Transaction Code     SPRO
    IMG Menu     Financial Accounting ® Accounts Payable Accounts Receivable  ® Business Transactions ® Incoming Payments  ® Manual incoming payments ® Define Tolerances (Customer)
    Regards

  • Difference between Filter and Variables

    Hi Experts,
    What is the difference between Filter and Variables except user can give input dianamically in the case of Variables??
    Thanks in Advance!
    Sapna

    HI,
    Both works similarly ....but if the requirement is fixed means u know what data should be displayed in the query then u can use the filters....if u want to give that option to the Users then we create a variable and user can enter the required data which he wants to view.....once u define filters then only that particular restricted data will be displayed in the query out put....but incase of variables we are having the flexibility to view the data....
    Thanks/Tarak

  • Difference between SDL Amount posted to finance and amount paid to CPFBorad

    Hi ,
    Singapore Payroll -help required:-
    My issue is: - -> Every month there is a difference between SDL Amount  posted to finance and amount paid to CPF board.
    Please find following SDL break down from Jan u2013 May 2011.
    SDL FI Posting :-/376
    Jan 11     Feb 11     Mar 11     Apr 11     May 11
    (1,313.05)     (1,220.27)     (1,119.66)     (1,087.04)      (1,339.28)
    SDL in CPF Report-  pc00_m25_ccpf     
    Jan 11     Feb 11     Mar 11     Apr 11     May 11
    (1,350.00)     (1,574.00)     (1,389.00)     (1,392.00)     (1,373.00)
    Diff           
    Jan 11     Feb 11     Mar 11     Apr 11     May 11
    (-36.95)     (-353.73)     (-269.34)     (-304.96)     (-33.72)
    What could be the possibility for the errors?
    Regards
    Thomas
    Edited by: Thomas Padiyara on Jun 14, 2011 4:34 AM

    Thx Srini..
    I have taken a list of wage types marked for SDF through report-PC00_M99_DLGA20
    Then have checked that does GLu2019s are mapped o all wage types through report RPDKON00.
    It seems to be fine.
    For evaluation calss -6 is used for monthly printing. Anyway that is not marked for any of the wage types.
    I have analyzed the details in QAS system for March month.
    The details are as follows:-
    1.     Wage type report - (S_PH9_46000172) = 1119.66
    2.     CPF report (PC00_ M25_CCPF) -1389.00.
    3.     Posting amount (credit amount 1389.85 sgd - debit amount 270.19 sgd) = 1119.66
    It seems to be the debit amount is also getting displayed in the CPF report.
    How the debit and credit amt is displaying same as for few employees.
    One example is given as follows:-
    WT     WT description               
    /305     E'yee,CPF-curr     2,539.00-Debit           SGD
    /305     E'yee,CPF-curr           2,539.00-Credit     SGD
    /305     E'yee,CPF-curr           1,152.00-Credit     SGD
    /307     E'yer,CPF port     2,031.00-Debit           SGD
    /307     E'yer,CPF port           2,031.00-Credit     SGD
    /307     E'yer,CPF port           923-Credit     SGD
    /370     E'yee, CDAC, a     1-Debit           SGD
    /370     E'yee, CDAC, a           1-Credit     SGD
    /370     E'yee, CDAC, a           1-Credit     SGD
    /376     E'yer, SDF                          11.25-Debit           SGD
    /376     E'yer, SDF                              11.25-Credit     SGD
    /37I     Total Medisave     45-Debit           SGD
    /37I     Total Medisave           45Credit     SGD
    /307 three entries (2 credit, one debit)
    /376 two entries (one credit, one debit)
    Why?
    Edited by: Thomas Padiyara on Jun 14, 2011 10:34 AM

  • XST Post-synthesis simulation differences between Virtex4 and Virtex6

    Hi
    I've been looking at  a problem we've been having in one of our components where a register interface that we have implemented doesn't seem to be behaving correctly. We've used ISE 14.1 and 14.6, and simulated in ISim and ModelSim 6.6d, which both display the weird behavior. I've attached the project, source, simulation and post-synthesis code which display the issue.
    We write a value (0x3FFF) to a register (in the case of the simulation 0xC) When that register is read back, we would expect 0x3FFF on reg_response_rdata. Indeed with pre-synthesis simulation, and post-synthesis on Virtex4, this is what we find. However on Virtex6 the response is 0x8000. Through trial and error we can fix this by changing line 98 of the source to the commented out line 99. Note that the implementation of pad_reg and pad_vector are identical, save for pad_vector taking the length as an argument.
    To recreate run ab_dc.do in your favourite simulator. This simulates a register write to pre and post synthesis models. Notice the reads return different results depending on which hardware has been synthesised, and depending on whether pad_reg or pad_vector are used. Note also that the change to fix the behavior on line 98/99 isn't the same register that we try to write to/read from.
    When it is broken (ie using pad_reg) we get the following warning: WARNING:Xst:2999 - Signal 'debug_counter', unconnected in block 'ab_dc_pre_comp', is tied to its initial value. I'm not sure what the initial value of debug counter can/should be. This warning doesn't appear when using pad_vector.
    Files in zip:
    ./ab_dc.vhd                                                                                The source
    ./WarningOutput.txt                                                                   A comparision of the warnings from ISE14.1 when compiling for Virtex6. Broken = pad_reg, Fixed = pad_vector
    ./xilinxTest.ise                                                                           The ISE project file
    ./netgen/synthesis/v4_ab_dc_comp_synthesis.vhd                  ab_dc.vhd synthesised for Virtex4 using ISE14.1 using pad_reg
    ./netgen/synthesis/v6_ab_dc_comp_synthesis.vhd                  ab_dc.vhd synthesised for Virtex6 using ISE14.1 using pad_reg
    ./netgen/synthesis/v6_fix_ab_dc_comp_synthesis.vhd            ab_dc.vhd synthesised for Virtex6 using ISE14.1 using pad_vector
    ./sim/ab_dc.do                                                                           TCL to compile and run simulation
    ./sim/ab_dc_tb.vhd                                                                    Simulation to write to register 0xC and then read from it.
    ./sim/wave.do                                                                            Useful signals to recreate problem
    This looks to me like a bug in XST. I'm happy to be proven wrong though!
    Thanks

    
    Looks like a parser issue to me, in case of V4 device XST uses an old parser and for V6 devices XST uses new parser. Check below AR:
    http://www.xilinx.com/support/answers/32927.html
    Thanks,
    Anusheel
    Search for documents/answer records related to your device and tool before posting query on forums.
    Search related forums and make sure your query is not repeated.
    Please mark the post as an answer "Accept as solution" in case it helps to resolve your query.
    Helpful answer -> Give Kudos
    -----------------------------------------------------------------------------------------------

  • Credit Management: Difference Between Static and Dynamic Credit Check

    Hi,
    Could anyone tell the difference Between Static and Dynamic Credit Check?
    According to website: http://www.sap-basis-abap.com/sd/difference-between-static-and-dynamic-credit-check.htm ... this is the answer:
    ====================
    Simple Credit Check : Tr.Code - FD32
    It Considers the Doc.Value + Open Items.
    Doc.Value : Sales Order Has been saved but not delivered
    Open Item : Sales Order has been saved , Delivered, Billed & Transfered to FI, but not received the payment from the customer.
    Static Credit Check it checks all these doc value & check with the credit limit
    1) Open Doc.Value / Sales Order Value : Which is save but not delievered
    2) Open Delivery Doc.Value : Which is delivered but not billed
    3) Open Billing Doc.Value : Which is billed but not posted to FI
    4) Open Item : Which is transfered to FI but not received from the customer.
    Dynamic Credit Check         1) Open Doc
                                                2) Open Delivery
                                                3) Open Billing
                                                4) Open Items
                                                5) Horizon Period = Eg.3Months
    Here the System will not consider the above 1, 2, 3 & 4 values for the lost 3 months.    
    ====================
    Question 1: Could you further explain the above information, if there is any?
    Question 2:: What is the Tcode to customize settings of:
    a) Simple Credit Check (isn't this same with b) below?)
    b) Static Credit Check
    c) Dynamic Credit Check

    Hi Tanish,
    Diff between Static and Dynamic Filters.
    Example One at report Level.
    Create a variable for a Infoobject say ,Material .
    1)In the Query Designer and if u restrict it to some 10 materials at query level, the report will display for only those 10 materials only.This is Static Filter.UR AHrdcoding it to those materials.You cant change them at Query Run time.i.e not changeable by user.
    2)If u give the variable as input ,and when u run the query ,u can can choose the material,may 10 may be 1 or may 20 .It is dynamic.Changeable by user at run time
    Example Two at DTP and Start Routine Level,say Document Type.
    1)If u give filters in Start routine it is Static as u cannot change it in Production,not changeable by user.
    2)f u give filters in DTP it is Dyanamic as u can change it in Production.U can give any doc type,Changeable by user at run time.
    Hope it is Understood.
    Rgds
    SVU

  • What is the difference between occurs0 and occurs1

    pls explain about the difference between occurs0 and occurs1 in sap-abap.

    Hi  Suresh,
    WELCOME TO SDN
    Please check this link
    diff b/w occurs 0 and 1
    Occurs 0 and Occurs 1...
    Occours 0
    Occurs 1 allocates 1 unit of memory(Sufficient to hold one record) and and when one record is appended, one more unit of memory is allocated.
    Occurs 0 will allocate memory dynamically.It will not allocate any memory when the itab is declared.
    Coming to performance: If you know that you will store only one single value in the Internal table If you use OCCURS 1. It would perform well than OCCURS 0.
    Occurs 0 keeps on incrementing when there is a value. But Occurs 1 will assign a single space even though there is no value.
    Lets suppose you did not get any values from the DB after a select, in this case if you write Occurs 0 it will not allocate any single space in the memory. If you write OCCURS1 it will pre allocates some memory.
    Hope this helps...
    Best regards,
    raam

  • Difference between Macros and subroutines

    Hi experts can any one tell difference between macros and subroutines.

    1) Macros can only be used in the program the are defined in and only after the definition are expanded at compilation / generation. Subroutines (FORM) can be called from both the program the are defined in and other programs . A MACRO is more or less an abbreviation for some lines of code that are used more than once or twice. A FORM is a local subroutine (which can be called external). A FUNCTION is (more or less) a subroutine that is called external. Since debugging a MACRO is not really possible, prevent the use of them (I’ve never used them, but seen them in action). If the subroutine is used only local (called internal) use a FORM. If the subroutine is called external (used by more than one program) use a FUNCTION
    2)  The macros, which we may use,
    (stored in table TRMAC)
    , we cannot debug that code.
    3) where as in subroutine,
    its a abap code, directly visile in
    the editor,
    and we can debug this code.
    4) MACROS =>
    Getting a feel of macros
    The basic syntax of macros is as follows:
    DEFINE macro_name. "Macro Definition
    ……………. Statements
    ……………. Statements
    END-OF-DEFINITION. "Macro Definition
    macro_name par1 par2 …par9. "Macro call -parameters separated by spaces
    Within the DEFINE... and END-OF-DEFINITION lies the body of the macro—the statements that you wish to be executed each time the macro is called. These statements may be any valid ABAP statements, such as WRITE, CLEAR, FORM calls, or database statements such as SELECT or UPDATE.
    To familiarize yourself with the working of macros, it's necessary to take a close look at exactly what happens when an ABAP program containing a macro call is generated. Consider Listing A.
    All ABAP programs must be generated before they can be executed. At the time of program generation, the system supplants each macro call, as shown in Listing A, with the statement(s) placed between the macro definition. Furthermore, the parameters passed at the time of macro calling are copied in place of the any placeholders (numbered &1, &2 …&9) found in the body of the macro definition. The system simply ignores the presence of the macros during the execution of the program—that is, all statements are executed as a single block of code:
    write : int1.
    write : int2.
    write : int3.
    Other than readability and meaningfulness, macros also offer performance advantages. For testing purposes, I wrote a macro that incremented the value of a variable by 1 and called the macro N times via a DO loop, as shown here:
    DEFINE INCREMENT.
    ADD 1 TO &1.
    END-OF-DEFINITION.
    DO N TIMES.
    INCREMENT VAR1.
    ENDDO.
    SUBROUTINES=>
    Subroutines
    You call subroutines from ABAP programs using the PERFORM statement.
    Subroutines are introduced with the FORM statement and concluded with the ENDFORM statement.
    You can define subroutines in any ABAP program. You can either call a subroutine that is part of the same program or an external subroutine, that is, one that belongs to a different program. If you call an internal subroutine, you can use global data to pass values between the main program and the subroutine. When you call an external subroutine, you must pass actual parameters from the main program to formal parameters in the subroutine.
    *U Shud start rewarding helpfull answers*
    amit

  • Difference between NLS_LANG and LANG

    Hi all,
    May i know the difference between NLS_LANG and LANG? Currently they are set as NLS_LANG=american.america.WE8ISO8859P1 and LANG=c as my environment variables. Will it post any problem for the future usage of Oracle? Thanks.

    AFAIK, LANG is not related to Oracle. For an explanation of NLS_LANG, see MOS Doc 158577.1 (NLS_LANG Explained (How does Client-Server Character Conversion Work?))
    HTH
    Srini

  • What is the difference between timestanp and vtimestamp?

    Some script uses variable "timestamp" , and some uses "vtimestamp".
    I can't understand exact difference between timestamp and vtimestamp,
    though I found description as follows.
    timestamp
    The current value of a nanosecond timestamp counter. This counter
    increments from an arbitrary point in the past and should only be
    used for relative computations.
    vtimestamp
    The current value of a nanosecond timestamp counter that is virtualized
    to the amount of time that the current thread has been running on a CPU,
    minus the time spent in DTrace predicates and actions. This counter
    increments from an arbitrary point in the past and should only be used
    for relative time computations.
    Would you explain the difference?
    Thank you.

    "timestamp" evaluates to the current value of a system-global 64-bit nanosecond counter, available (and documented) in gethrtime(3C) from C programs. Values of "timestamp" from different threads can be directly compared.
    "vtimestamp" is a 64-bit thread-local nanosecond counter which counts time the thread has spent on-CPU, excluding time spent processing dtrace probes and actions. (It is similar to gethrvtime(3C), but not identical to it -- gethrvtime(3C) includes dtrace processing time). The only operation on vtimestamp values which gives a meaningful result is subtracting two values from the same thread to get "time spent on-CPU" between two probe points for that thread.
    (at the moment, vtimestamp will include time spent doing high-level interrupt processing while the thread is on-CPU. In the future, that will probably be corrected.)

Maybe you are looking for

  • Populating data in R/3 PO from SRM PO

    Hi- We are running SRM 4.0 in an extended classic scenario.  We are currently capturing the UNSPSC code in the MFR_NO_EXT field in the line item of the cart.  This data is flowing through to the same field on the line item of the PO in SRM.  However,

  • Not able to find AIA2.5 installable for Windows 64 bit

    Hi Friends, I am not able to find the installable of AIA 2.5 for windows platform (64 bit) at oracle e-delivery. I have installed SOA 10..1.3.5.0 with OC4J, now I need to install AIA 2.5 and then Customer MDM (UCM) PIP over it as a project requiremen

  • Iphone 5 not syncing music correctly

    Wondering if theres anyone out there in internet world that can help me . I have a macbook air thats running yosemite and an iPhone 5 on the latest iOS . Recently I've been having quite a lot of trouble syncing music from iTunes to my iPhone . By tro

  • How to refresh portlet??

    I have couple of questions. Please help me by giving the answers. 1) How to refresh only portlet not whole page? 2) If I can refresh only portlet, is there any property to set so that i can refresh periodicaly? 3) What is Cache expire property in por

  • Time reduction  for  getting materials as per plants, login from R/3

    Hi All, I am technical person working on SRM . Our SRM configuration uses the ITS for the end user to login to SRM server. The requirement is that, the user logged into the SRM must see the material for the plants which they are assigned in org. stru