Doubt in Basic Arithmetic Operators' behavior

Hi all,
The Java Language Spec says that, the arithmetic operators +(Binary additive) and ++(increment) both return a integer value.
So, while using a code like this,
byte a=5;
byte b = a+1;
The compiler throws an error which is perfectly valid. But the same should happen when we use
a = ++a;
But the compiler does not throw any error.
Can anybody explain about this?
Thanks in advance!
Dinesh.V

byte a=5; // No error. 5 is an int, but compiler knows that 5 fits into a byte.
byte b = a+1; // Error. Compiler doesn't know if a + 1 will fit into a byte.
a = ++a; // No error. Type of ++a is byte because a is a byte.b = ++a; // No error. Type of ++a is a byte because a is a byte.

Similar Messages

  • Doubt in Basic ABAP.

    Hi Gurus,
    I have a small doubt in basic ABAP.
    What is the exact difference between the below statements.
    Types: Begin of ty_data,
                 matnr type mara-matnr,
              end of ty_data.
    Types: Begin of ty_data,
                 matnr type matnr,
              end of ty_data.
    Types: Begin of ty_data,
                 matnr like mara-matnr,
              end of ty_data.
    Types: Begin of ty_data,
                 matnr like matnr,
              end of ty_data.
    data: matnr type mara-matnr.
    data: matnr type matnr
    data: matnr like mara-matnr
    data: matnr like matnr.
    In those above statement which are correct. And the difference between those statements.
    Thanks,
    Srihari.

    hi,
    LIKE means the datatype of the variable is similar to the referenced variable.
    TYPE means it is a predefined data type.
    Eg:
    DATA int TYPE i.
    Here int is of integer data type.
    DATA var LIKE int.
    var IS a variable having same data type of int. which in turn is integer.
    You can find these helpful when you reference database table variables... You need not know what is the datatype defined.
    Also it adds to FLEXIBILITY.
    Whenever you make changes to your database tables and fields,
    that change is REFLECTED back to your program that is,
    You need not change all your program code when you change your table fields...
    Hope you understand and appreciate the flexibility that SAP provides to the programmers...
    Thanks
    Arun

  • I've a doubt in basic thing.

    Hi all
    I've a doubt in basic thing.
    IActiveContext* myContext;
    InterfacePtr<ITextEditSuite> textEditSuite(myContext->GetContextSelection(), UseDefaultIID());
    textEditSuite->InsertText(WideString(rString));
    in above lines, myContext->GetContextSelection() returns ISelectionManager. Then how textEditSuite can be created. could any one please explain?
    thanks in advance
    Ays.Hakkim

    HI
    But you already creating "textEditSuite" from ISelectionManager. In That code that you pasted above.
    To get ISelectionManager you can either use IActiveContext::GetContextSelection or ISelectionUtils.
    Let's say you have a an interface pointer to ISelectionManager named mySelectionMgr;
    All you need to do is create your interface pointer to ITextEditSuite - textEditSuite:
    InterfacePtr<ITextEditSuite> textEditSuite(mySelectionMgr, UseDefaultIID());
    if (textEditSuite && textEditSuite->CanEditText())
         ErrorCode status = textEditSuite->InsertText(WideString(resultString));
         ASSERT_MSG(status == kSuccess, "WFPDialogController::ApplyFields: can't insert text");
    This is code from InDesign SDK Documentation. You can find there more examples of "How to use ITextEditSuite".
    Regards
    Bartek

  • Basic Motion Spin Behavior has the 2 arrows missing

    In the HUD, why are the 2 rounded arrows in the center missing in the Basic Motion "Spin" Behavior? The outer circle appears, but the center is black, not allowing access to the rotation axis.

    I had the same issue on my 8-core Mac Pro. I solved the issue by removing the extra video card I had in the system. Now I am using two cinema screens on one Gforce 8800 GT and Motion works fine again, including the spin behavior's HUD.
    Hope this will help.

  • Doubt in Basic Bapi function

    Hi experts,
    I have a small doubt in BAPI, Actually i want to add the vendor price only in MEK1. For that am using BAPI to add the vendor price.
    Can anyone tell where we need to write the source code? We need to write a report program? How it will trigger the particular transaction?
    Can any one explain this?
    Mohana

    Hi Mohana,
    for that you need to seacrh for the BADI or Userexit,...when ever any changes are maded in that transaction based one the situation your BADI or userexit will trigger and that will update to the data base...if you use that BAPI in that EXIT.....
    if you are using separatly the program...every time you need to execute that program for updating that field in that transaction...
    Thanks!

  • Proper arithmetic operators

    Hi, all!
    When using the following calculation, expecting to get a percentage, I get 100 as the result for surferHappyRatio over and over. Am I missing something stupid here? The size of the 'badNeighbors' array is 1 up to 8, with null space filling out the array so that there's always 8 spaces around a Surfer.
              totalBadNeighbors = badNeighbors.size();
              float r = totalBadNeighbors / 8;
              float f = r*100;
              int surferHappyRatio = 100-((int)f);
              System.out.println("==> happyRatio successfully calculated at " + surferHappyRatio);
              

    Learn to do some basic debugging:
    totalBadNeighbors = badNeighbors.size();
    System.out.println( totalBadNeighbors );
    float r = totalBadNeighbors / 8;
    System.out.println( r );
    float f = r*100;
    System.out.println( f );
    int surferHappyRatio = 100-((int)f);
    System.out.println("==> happyRatio successfully
    calculated at " + surferHappyRatio);What good does it do to only print out the final
    value if you don't know what the indermediate results
    are?I deserved that--I should have told you all that I already tried some debugging and just didn't show you that. Here's the problem (I'm channeling Adrian Monk): the answer to System.out.println( totalBadNeighbors ) was 3 in the test case. Obviously, I should get 0.375 as the answer to System.out.println( f ), but I'm not. I believe I've properly cast the variables--what in heaven's name am I missing? float/float = float, right?

  • How ODI works? Doubt in basic Architecture.

    Hi,
    I need to know how ODI (Architecture) works on basic transformations. From my understanding,
    1) ODI extracts the data from source, create some temp tables in Staging Area and put the data in temp table.
    2) From that temp table it puts the data to target and drop the temp table.
    is the two statements are correct? one more thing is that i am confident on 3rd point, please say wether its right.
    3) We can make all the temp tables to be created in a different database without affecting the target database (Using the option"Staging area diff from target")
    Any suggestions would really help.
    Thanks in Advance,
    Ram Mohan T

    Hi,
    Thanks a lot for your reply. I need no temporary tables should be created in target database. For that, i have taken
    Source and target from different databases and staging area as different database (in total three database for source, target and staging area).
    I used these knowledge modules - LKM Sql to Sql, IKM Oracle Incremental update, CKM oracle.
    When i execute the interface, two tables are created in target database (SNP_Check_tab, E$_emp_table), how can i avoid that.
    Any suggestions would really help.
    Thanks in Advance,
    Ram Mohan T.

  • Doubt in basic stuff

    Hi all,
    I have installed 10g app server and also new to 10g.
    My doubt is , is there any way to created domain in 10g app server as in weblogic .
    Please reply to this.
    Srini

    Hi all,
    I have installed 10g app server and also new to 10g.
    My doubt is , is there any way to created domain in 10g app server as in weblogic .
    Please reply to this.
    Srini

  • Arithmetic operators

    Hi experts,
    I need this : I have my variable num_pack = 0,04 type i.
                       I need my variable becomes 1.
                       Which operator do I need ( if exists ) ?
    Thanks in advance.
    Marco

    you have to call a function module to round always up.
    I dont remeber the exact name
    go SE37 and search for it by entering  round and hit F4.

  • Arithmetic Operators Help

    I've just started my Java programming class, and my book is not in from Amazon yet. So, please let me know if I recall these correctly from a previous Introduction to Java class from a fews years ago.
    The value of 5/2: 2
    The value of 5.0/2: 2.5
    The value of 5%2: 1
    The value of 2%5: 2
    Thanks for your help!

    You don't need a book or our help here. Just download the java compiler, read the first few tutorials to get it up and running and run a small program to see if your expectations match your findings. This is the best way to discover programming.

  • Arithmetic Operators Problem!

    int a,b;
    long c,d;
    a=12345;
    b=234567;
    c=a*b/b;
    d=(long)a*b/b;
    the Result:
    c= -5965
    d= 12345
    why ?

    Please see the expression broken into smaller expressions
    int a,b;
    long c,d;
    a=12345;
    b=234567;
    c=a*b/b;
    int temp1 = a*b; // here we can expect lossed values in temp1
    int temp2 = temp1 / b; // temp1 already corrupted
    c = temp2 ;
    // So instead do casting here
    c = (long)a*b/b; // Good luck
    d=(long)a*b/b;
    the Result:
    c= -5965
    d= 12345
    why ?

  • Doubt on basic  concept

    Say we have a class called Animal which has a method called shout().
    we have another class called Dog which has a method callled bark().
    Dog class extends Animal class.
    so Dog class has 2 methods now
    1)shout()
    2)bark()
    If we declare like this
    Animal a=new Animal();//valid statement
    a.shout();//valid statement
    Dog d=new Dog();//valid statement
    d.shout();//valid statement
    d.bark();//valid statement
    Animal a=new Dog();
    a.shout();//valid statement
    a.bark();//invalid since type of reference variable is Animal
    Dog d=new Animal();
    why the above decalration is not valid?
    Animal object has shout() method
    By inheritance Dog class has both shout() and bark() methods.
    So with above type of declaration d.shout() should execute.But that is wrong.
    A subclass reference variable cannt point to a subclass object.I know this kind of statement.But can any one explain why?

    kirn291 wrote:
    Dog d=new Animal();
    why the above decalration is not valid?To a Dog variable you can only assign objects which are of type Dog, and Animal isn't.
    A Dog object is both of type Dog and of type Animal. This means Dog objects can be assigned to both Dog variables and Animal variables.

  • Cannot view arithmetic operators in Preview

    I can't seem to view this math related document correctly:
    "http://www.stewartcalculus.com/data/default/upfiles/LiesCalcAndCompTold.pdf".
    Message was edited by: Pleasehelp05

    I don't know why it does not work in Leopard, when it worked OK in Tiger.
    For the Adobe Reader issue with installation, you may want to run +Repair Disk Permissions+ in Disk Utility if you have not done that recently. Then, try it again.

  • Arithmetic Quiz (Small Basic)

     Primary school teacher wants a computer program to test basic arithmetic

     Primary school teacher wants a computer program to test basic arithmetic
    And you are the student?
    Have you downloaded Small Basic? If not, go to
    www.smallbasic.com.
    Try searching on TextWindow.WriteLine().
    One hint is to put some math in those parentheses.
    Experiment! That's the fun!
    Thanks!
    Ed Price, Azure & Power BI Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • Basic formula in Numbers 09

    Hi, guys, I try to make a basic formula in Numbers but do not find the way.
    I just need put numbers in two columns and get the result of dividing or multiplying in the third column.
    Say ColumnB : ColumnC = ColumnD
    Can you please help me? Tried to find in the functions list on the Apple web-site but no way.
    Thanks for help ))))

    Markiz wrote:
    Can you please help me? Tried to find in the functions list on the Apple web-site but no way.
    Thanks for help ))))
    Both the Numbers '09 User Guide (which covers the use of the arithmetic operators ( + - * / ) and the iWork Formulas and Functions User Guide (which discusses QUOTIENT and the rest of the functions supported in Numbers and the other iWork applications) can be downloaded through the Help menu in Numbers.
    Regards,
    Barry

Maybe you are looking for

  • Re: Satellite L450D Cannot delete file from desktop

    Hi all, I was veiwing some photos on yahoo email via firefox version 3 6 3 sent by my sister in Australia, when this file appeared on my desktop which I cannot delete. The file is called Pez & Lisa (after my sister and brother in laws photograph) whe

  • Not Like in SQL not working

    Trying to use not like in the following sql: select * from respondents where sample_id = 00000001 and email not like '%cccp.org%'; Right now, I'm getting back 51 rows, but 1/2 of the rows have the wrong domain in the email fields, and I need to filte

  • Word 2003 Document Won't Convert

    Trying to convert a Word 2003 document with some graphics.  Conversion process seems to stall mid-point.  Waited 23 minutes and gave up.  Suggestions?  Thanks! Susan

  • Acrobat Reader X ne repond plus lors de l'impression (environement Citrix)

    Bonjour, Je fais façe à un problème qui touche l'enssemble de ma société (150 users), depuis le passage à Acrobat Reader X. Nous travaillons sous un environement Citrix et Windows serveur 2008 standard editions, SP2 (x86). Le problème : Lors de l'imp

  • Costing with special procurement

    Hi , I have bunch of materilals in 2 palnts (Say A,B) two different company ocdes(Say X,Y) , one plant  (B) which is having F/-/aa , where F is Extrenal Proc/Mrp special -/aa is the Costing Special Proc.key pointing Plant "A" as primary plant I coste