Questions on shift operators in java

Hi,
I have two questions and I would be grateful if you could give some suggestions.
1. int x = -1; x = x >>> 32;Can you suggest the value of x after this operation. I thought it would some positive number, but I am wrong.
2. What is -50 >> 1 ?Can you suggest the answer for this one too? I thought it would be "a negative number with very large magnitude", but it seems I am wrong on this one too.
Thanks a lot for your answers!

priyankabhar wrote:
2. What is -50 >> 1 ?
">>" is arithmetic shift right, it shifts in copies of the sign bit; so if your number was negative, it shifts in 1's; otherwise it shifts in 0's. The effect of this is dividing a signed number by 2^(number of bits you shifted), rounding down towards negative infinity.
So the answer is -25 (-50 / 2); you didn't have to worry about rounding in this case.
priyankabhar wrote:
I thought it would be "a negative number with very large magnitude"how did you figure that?

Similar Messages

  • How do Shift Operators work?

    Pls I am just beginning to write simple programs in java,
    and would like to know how precisely shift operators
    (e.g >> << >>>) work.
    Thank you in anticipation.

    I am a student, and have read my notes yet could not be
    clear about the shift operators actually work (function).
    Pls assist!Here's a start:
    Compile and run the following line:System.out.println("33 << 4 == "+(33 << 4));which should print something like this:33 << 4 == 528Now, if you write down the binary representations of the numbers 33 and 528, you'll get: 33 == 00000000 00000000 00000000 00100001
    528 == 00000000 00000000 00000010 00010000 Do you now see how the 4 is related to the operation?

  • How can I change the Arabic question mark (shift +...

    I have a Nokia E72 that was purchased from Dubai. All default languages are changed now to English. Even the "Writing Language" is in English. But when I type a text message, the keyboard key for the question mark (shift + L) comes up in Arabic. Is there a way to change this (either a quick fix or one going through the OS) to permanently appear in English?

    Security questions:
    https://discussions.apple.com/docs/DOC-4551
    http://support.apple.com/kb/HT5312

  • Questions on SAP Biller Direct Java Customization

    Hi,
    I am working on SAP Biller Direct java customizations. Can anyone help me find answers to these questions.
    --  I have created local DC from the Biller direct track in NWDI. I would like to change the User registration page in Biller Direct.
    Can any one let me know the JSP page name for that and where can i find it in the components.
    --- Also all this development do i have to do it in J2EE perspective and checkin my changes?
    Also i would like to know if anyone can send some documents on devlopment part of Biller direct.
    Thanks
    Edited by: Aparna on Aug 20, 2009 12:33 PM

    Hi Aparna,
    I have a couple quick questions about BD development and would really appreciate it if you could provide some advice since we are starting our build soon.
    In my NWDI track, I have component FSCMBD and several other of the required SAP components. I did not create a new product or component, just followed the procedure in this thread: https://forums.sdn.sap.com/thread.jspa?threadID=1331894. Is that the method you recommend?
    I am concerned about doing development directly on the FSCMBD component. How do I prevent my developers from modifying BD source code? Is the idea that they will create independent DCs in NWDS (as you described) and only modify those? I just want to make sure that we are doing development in a way that is supported and will not cause issues when applying SPs or upgrades to FSCMBD.
    I also want to confirm that this "create project" activity is not something that I need to do as an Administrator in the NWDI track; this is something my java developers will need to do in NWDS at the beginning of the build.
    Thanks Aparna!
    - Michelle

  • Questions/answers from jsp to java bean

    Hi
    This is what i need to do .
    I am showing some questions, say 4 of them , and radio buttons(yes/no) as answers in the JSP.
    Now how do i transfer these questions and their answers from jsp to java bean .
    I did try hashmap ,but not quite working .
    any help?
    thanks

    Name each radiobutton differently, and then provide 1 property and accessor methods for each of your four answers in the JavaBean, with the same name as specified in the HTML FORM.
    So in the HTML:
    <input type="radio" name="answerOne" value="true"...>
    and then have a property named answerOne with accessor methods in the javaBean...

  • Question about main difference between Java bean and Java class in JSP

    Hi All,
    I am new to Java Bean and wonder what is the main difference to use a Bean or an Object in the jsp. I have search on the forum and find some post also asking the question but still answer my doubt. Indeed, what is the real advantage of using bean in jsp.
    Let me give an example to illustrate my question:
    <code>
    <%@ page errorPage="errorpage.jsp" %>
    <%@ page import="ShoppingCart" %>
    <!-- Instantiate the Counter bean with an id of "counter" -->
    <jsp:useBean id="cart" scope="session" class="ShoppingCart" />
    <html>
    <head><title>Shopping Cart</title></head>
    <body bgcolor="#FFFFFF">
    Your cart's ID is: <%=cart.getId()%>.
    </body>
    <html>
    </code>
    In the above code, I can also create a object of ShoppingCart by new operator then get the id at the following way.
    <code>
    <%
    ShoppingCart cart = new ShoppingCart();
    out.println(cart.getId());
    %>
    </code>
    Now my question is what is the difference between the two method? As in my mind, a normal class can also have it setter and getter methods for its properties. But someone may say that, there is a scope="session", which can be declared in an normal object. It may be a point but it can be easily solved but putting the object in session by "session.setAttribute("cart", cart)".
    I have been searching on this issue on the internet for a long time and most of them just say someting like "persistance of state", "bean follow some conventions of naming", "bean must implement ser" and so on. All of above can be solved by other means, for example, a normal class can also follow the convention. I am really get confused with it, and really want to know what is the main point(s) of using the java bean.
    Any help will be highly apprecaited. Thanks!!!
    Best Regards,
    Alex

    Hi All,
    I am new to Java Bean and wonder what is the main
    difference to use a Bean or an Object in the jsp. The first thing to realize is that JavaBeans are just Plain Old Java Objects (POJOs) that follow a specific set of semantics (get/set methods, etc...). So what is the difference between a Bean and an Object? Nothing.
    <jsp:useBean id="cart" scope="session" class="ShoppingCart" />
    In the above code, I can also create a object of
    ShoppingCart by new operator then get the id at the
    following way.
    ShoppingCart cart = new ShoppingCart();
    out.println(cart.getId());
    ...Sure you could. And if the Cart was in a package (it has to be) you also need to put an import statement in. Oh, and to make sure the object is accessable in the same scope, you have to put it into the PageContext scope. And to totally equal, you first check to see if that object already exists in scope. So to get the equivalant of this:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart"/>Then your scriptlet looks like this:
    <%@ page import="my.pack.ShoppingCart %>
    <%
      ShoppingCart cart = pageContext.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        pageContext.setAttribute("cart", cart);
    %>So it is a lot more work.
    As in my mind, a normal class can also
    have it setter and getter methods for its properties.True ... See below.
    But someone may say that, there is a scope="session",
    which can be declared in an normal object.As long as the object is serializeable, yes.
    It may be
    a point but it can be easily solved but putting the
    object in session by "session.setAttribute("cart",
    cart)".Possible, but if the object isn't serializable it can be unsafe. As the point I mentioned above, the useBean tag allows you to check if the bean exists already, and use that, or make a new one if it does not yet exist in one line. A lot easier than the code you need to use otherwise.
    I have been searching on this issue on the internet
    for a long time and most of them just say someting
    like "persistance of state", "bean follow some
    conventions of naming", "bean must implement ser" and
    so on. Right, that would go along the lines of the definition of what a JavaBean is.
    All of above can be solved by other means, for
    example, a normal class can also follow the
    convention. And if it does - then it is a JavaBean! A JavaBean is any Object whose class definition would include all of the following:
    1) A public, no-argument constructor
    2) Implements Serializeable
    3) Properties are revealed through public mutator methods (void return type, start with 'set' have a single Object parameter list) and public accessor methods (Object return type, void parameter list, begin with 'get').
    4) Contain any necessary event handling methods. Depending on the purpose of the bean, you may include event handlers for when the properties change.
    I am really get confused with it, and
    really want to know what is the main point(s) of
    using the java bean.JavaBeans are normal objects that follow these conventions. Because they do, then you can access them through simplified means. For example, One way of having an object in session that contains data I want to print our might be:
    <%@ page import="my.pack.ShoppingCart %>
    <%
      ShoppingCart cart = session.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        session.setAttribute("cart", cart);
    %>Then later where I want to print a total:
    <% out.print(cart.getTotal() %>Or, if the cart is a JavaBean I could do this:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart" scope="session"/>
    Then later on:
    <jsp:getProperty name="cart" property="total"/>
    Or perhaps I want to set some properties on the object that I get off of the URL's parameter group. I could do this:
    <%
      ShoppingCart cart = session.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        cart.setCreditCard(request.getParameter("creditCard"));
        cart.setFirstName(request.getParameter("firstName"));
        cart.setLastName(request.getParameter("lastName"));
        cart.setBillingAddress1(request.getParameter("billingAddress1"));
        cart.setBillingAddress2(request.getParameter("billingAddress2"));
        cart.setZipCode(request.getParameter("zipCode"));
        cart.setRegion(request.getParameter("region"));
        cart.setCountry(request.getParameter("country"));
        pageContext.setAttribute("cart", cart);
        session.setAttribute("cart", cart);
      }Or you could use:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart" scope="session">
      <jsp:setProperty name="cart" property="*"/>
    </jsp:useBean>The second seems easier to me.
    It also allows you to use your objects in more varied cases - for example, JSTL (the standard tag libraries) and EL (expression language) only work with JavaBeans (objects that follow the JavaBeans conventions) because they expect objects to have the no-arg constuctor, and properties accessed/changed via getXXX and setXXX methods.
    >
    Any help will be highly apprecaited. Thanks!!!
    Best Regards,
    Alex

  • Newbie question on how to return java objects from java stored procedures

    Hi,
    As you may guess, i'm new to this.
    I have a stored procedure that does some calculations and creates a list of java objects as the result of the query.
    How would I return the list from the database to the client application?
    Would I have to create an Oracle type that maps to the java object?
    Please help.
    Jag

    Hi Jag,
    Your question is very vague (to me). Perhaps you could post what you have done so far? Have you tried looking through the Sample Code page of the Technet Web site, or tried searching the Ask tom Web site, or MetaLink?
    Good Luck,
    Avi.

  • Question: How can I convert Java portlets into iViews? ...

    Hi David,
    Thank you for reading this post.  Currently, I have java portlets and have
    some questions converting them to iViews.  I have the iView conditions
    listed below with my questions:
    <u><b>iView Conditions:</b></u>
    <b>1. Usage of Correct Naming Conventions:</b>  If possible, can you show me a sample of
    the correct naming conventions?
    <b>2. Single Sign On:</b>  If possible, can you please elaborate more on this and possibly provide
    an example?
    <b>3. Session State (During the entire usage of an iView, session state
    and transaction integrity must be maintained)</b>. If possible, can you please elaborate more on this and possibly provide an example?
    <b>4.  Browser Independence (An iView must work with all supported versions of at least one browser type supported by Enterprise Portal).</b>  If possible, can you list supported versions?
    <b>5.  Look and Feel (The iView must present data in the Enterprise Portal
    look and feel and allow for the different personalization options that
    are possible with the SAP Enterprise Portal).</b>  If possible, can you please elaborate more on this and possibly provide an example?
    <b>6. Error Messages (The iView must be implemented in a way that provides
    default/ relevant/ meaningful error messages)</b> If possible, can you please elaborate more on this and possibly provide
    an example?
    <b>7. No Hard-Coded Paths </b> I understand this but just to make sure, can
    you possibly provide an example?
    <b>8. Special Characters (iViews must be able to depict reserved HTML
    characters)</b>
    If possible, can you please elaborate more on this and possibly provide
    an example?
    Thank you so much for your time and look forward to your
    response.
    Thank you,
    Baggett

    Hi, this question is addressed to anyone who could help, my apologies for any confusion.
    Thank you,
    Baggett

  • Filter Question 1: Shift Field - when to shift it?

    And by "shift it", I'm really asking in what order to place it, relative to any other filters being applied. And is there a rule of thumb for this particular filter being first or last in the stack?
    The Specific Issue:
    I notice FCP applies the filter automatically when I add HD material to a standard def Timeline (see "Workflow" description below), where the extra material has a different "Field Dominance" than the main footage. This triggers a green render bar, which thankfully doesn't take long to process.
    But I'm starting to see some odd behavior when I then add other filters to one of these clips whose Fields have been automatically Shifted by FCP.
    Specifically, I've been testing MagicBullet's "Noise Reducer" filter on a few of these clips (ones where I've had to magnify the image more than it really wants to be), and once the absurdly long render finally finishes*, the playback of just these clips gets very wonky on my external monitor (with a flashing blue that eventually takes over the whole screen, but only for these clips -- and FinalCut's telling me there's nothing left to render).
    * and this is the subject of a whole 'nother filters-related question I've posted in this same forum
    Interestingly, when I drag the Shift Fields filter from its default top-of-the-stack position in the Viewer down to the bottom, so that it comes after the MB Noise Reducer -- and then wait for another huge render to finish -- now everything seems to play back fine.
    Both filters (FCP's Shift Fields and MB's Noise Reducer) are configured in their default settings, and this apparent conflict with the Shift Fields filter appears to not occur in relation to any other filters I've also been testing (such as Sharpen and Deflicker).
    So -- is this just one of these trial-and-error things, where you keep reordering the filters till they seem happy, or is there a reason why the automatically applied Shift Fields filter should always be last in the stack (even though intuitively it feels like something which should be applied first)?
    Any insights appreciated.
    Thanks,
    John B.
    Toronto
    *Workflow Description*
    (which might be of interest to other one-man-band, tight-budget videographers)
    +I'm currently cutting a series of videos done for a local theatre company. My A-cam is a Sony MiniDV shooting 4:3, and my Timeline is the basic NTSC-DV easy setup. I generally also set up a B-cam at a different angle, which is locked off to get a static shot of the full performing area. This camera is a compact AVCHD unit, shooting at full 1920x1080. I put its material on a separate video track, and when I need to cut to it I use the Motion tab to frame the shot, resize it, and crop in as desired. Sometimes I'll even keyframe a pan and/or slight zoom to give the effect of a human cameraperson following the action live. Since both cameras are recording continuously, I only have to sync up the two tracks once -- and the end product gives a reasonably convincing impression of a two-person shoot.+

    Clearly I need to check in with the Jolly Red Giant himself, since I'm wondering if he's the one I should be pointing my finger at with regard to a bizarre issue I'm encountering: trying to export a previously harmless sequence which now contains clips with two Red Giant / Magic Bullet filters -- all fully rendered, but the Export time is expanding faster than a Supernova.
    Thread is called "Renders Gone Wild", if you have any advice on what I should do.
    Thanks,
    jb

  • Theorical question about declaration/definition in java

    Hi, we know the difference between declaration and definition:
    -declaration: no memory is allocated.
    -definition: memory is allocated.
    In C/C++ if we want to define a variable we can make
    int x;or
    int x = 5; (we assign a value too)
    while, if we just want to declare we can make
    extern int x;Is there a way in java to simply declare a variable? According to me just arrays can be declared with
    String[] arrayString;while istructions like
    String myString;are definition as they allocate at least a String reference on the stack...am I wrong?

    Squall867 wrote:
    Hi, we know the difference between declaration and definition:
    -declaration: no memory is allocated.
    -definition: memory is allocated.That's not the definition I learned, back when dinosaurs roamed the earth, men lived in caves and used pterodactyls for airplanes, and computers were made of rocks.
    Is there a way in java to simply declare a variable? According to me just arrays can be declared withThis is a pretty meaningless question.
    In Java, whenever you declare/define a variable (there is no distinction), space is allocated for that variable. It's at least 1 byte for a byte or boolean, at least 2 bytes for a char or a short, at least 4 bytes for an int, float, or reference, and at least 8 bytes for a double or long. A given JVM implementation may actually use more bytes for any given type for word-alignment performance optimization.
    Is there a way in java to simply declare a variable? According to me just arrays can be declared with
    String[] arrayString;
    This declares a reference variable of type reference to array of String. It will occupy at least 4 bytes.
    while istructions like
    String myString;are definition as they allocate at least a String reference on the stack...am I wrong?This declares a reference variable of type reference to String. It will occupy at least 4 bytes.
    Note that an array reference variable is no different than any other reference variable.
    Also note that for any variable, whether it lives on the stack or on the heap depends only on whether it's a member variable or a local variable. If objects are allowed to be created on the stack in future versions of Java, that distinction will get slightly more complex.

  • Where is the best place to ask questions about NetBeans 6 for Java?

    When it comes to Java discussions, all I can think is this forum, but what about Java Desktop Applications using NetBeans IDE 6?
    Question/Query 1:
    I just like to ask how I can make the Database Application Template under the Java> Java Desktop Application> Database Application:
    Well, the the nice Frame with prebuilt components are good, but how can we customize the Window Icon? Has anybody in this forum and particularly Netbeans 6 users encountered the same scenario?
    Question/Query 2:
    How can I make a splash page with such a Database Application template too?

    Hello Andy,
    we talk about Photoshop, or? In this case you should use Photoshop General Discussion
    You will find all the (other) communities by clicking "Adobe Communities" on the top of the window. Please have a look at
    https://forums.adobe.com/welcome (see screenshot) and/or open "All communities"
    Hans-Günter

  • Captivate 8: How to add a button onto a question slide to invoke some java script?

    I have some question slides where the user has to guess an item on a picture. Because the picture is very small, I want to add a zoom button which calls a function in my LMS to popup the picture in a bigger window. I could not find a way to add a button where I can call java script, so I tried to solve this by using a smart shape with option "use as button" set and adding the java script action. This works fine for the popup but now the submit button on the slide no longer works. Clicking the submit button just disables the answers and stays on the current slide even if I did not click onto the shape button previously. How can I achieve my goal to display a bigger picture of an image on my slide on the users request?
    I also tried the "ImageView" widget, but this is not a practicable solution.
    Thanks,
    Martin

    I think I found the solution: In the "Timing" tab for the shape there is an option "Pause After" which was set to 1,5 seconds. I cleared this options and now the submit button is working again.
    Martin

  • Question with SIMPLEDATE FORMAT in Java

    How can I convert my Date field in the the format I want with Simple Date format.
    Calendar cal1 = Calendar.getInstance(TimeZone.getDefault());
                   String DATE_FORMAT = "yyyy-MM-dd"; //
                   java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);
                   sdf.setTimeZone(TimeZone.getDefault());
                   String now = sdf.format(cal1.getTime());This code gives me the format I want, if I use a String , but I want to have this format in my DATE filed called START_DATE.
    How can I do that?I am sorry, I am learning Java, so this might be very idiotic questions to ask..but if anybody can help me??
    Thanks,
    Edited by: ASH_2007 on Mar 18, 2008 10:30 AM

    Yes, I know how to do that for a String.
    But how do I do the same thing for Date fields?I believe I already mentioned that is non-sensical in java. There is no such thing as a "date field".
    There is a Date object. And you use SimpleDateFormat to display it.
    There are datatypes in a database that are associated with timestamp values. And I already explained to you that, as you have already found out, that datatype holds a timestamp. It does not hold a date (just a date) and it never will. It is not possible.
    In terms of displaying (not storing) something in the database itself, not java, the way that you do that depends on the database.
    But regardless of the database you MUST still do something in terms of DISPLAYING it to make a timestamp appear as display value that looks like a date.
    Now exactly which parts of the above do you not understand????
    Stop telling us what you want to do and start asking questions about what we said - because it is obvious that you are having problems with concepts, not code. And until you understand the comments you can't phrase a question correctly so that one can answer it with code.

  • Question about creating Forms in Java.

    Hello , im new to Java , i find kinda weird how Java creates Forms , its pretty simple in Oracle Forms ,
    why did Java designers make it this difficult ? do people say this is something bad about Java ?
    when i learned about the Layout Managers that Java provides i found out how much code one have to write just to create a simple form ,my question to the experienced java developers : what do you do to create a form , do you hard code it ? , or do you use something like GUI Builder in an IDE like NetBeans for example? and is the code generated by this builder easy to deal with and modify ?
    Thanks ....

    HeavenBoy wrote:
    Hello , im new to Java , i find kinda weird how Java creates Forms , its pretty simple in Oracle Forms ,
    why did Java designers make it this difficult ? do people say this is something bad about Java ?Some Oracle Forms fans certainly do. But the truth is that Oracle Forms application tie down all the components in fixed pixels. The typical Swing form can be resized and can function at different screen resolutions. So, when designing a Java form, we don't tend to work on a fixed grid but define the sizes and positions relative to other components. What's more the interface between the form elements and the data is completely flexible, and flexibility means extra effort.
    >
    when i learned about the Layout Managers that Java provides i found out how much code one have to write just to create a simple form ,my question to the experienced java developers : what do you do to create a form , do you hard code it ? , or do you use something like GUI Builder in an IDE like NetBeans for example? and is the code generated by this builder easy to deal with and modify ?
    Most I've tried have been a bit of a straitjacket, but I've recently been using the latest Netbeans offering and it's pretty good. I think the breakthrough was the introduction of the GroupLayout layout manager. This is a layout manager really designed for WYSIWYG form designers (pretty challenging to use hand coded).
    The way these things work is that the class generated contains some methods which cannot be edited by hand, but you can add any amount of your own code without interfering with the generated code. You hook your own code snippets into the generated code, for example you can select a property of an object, say the model of a JTree, and select "user code", then type in an expression returning the TreeModel you want to use.
    With listeners the designer will generate the method signature etc. but you can edit the body of the listener method.
    However I would always recommend that you hand code a form or two before resorting to on of these editors because it's important you understand the code, even where a designer writes it.

  • Follow up to web services question:  How do I expose java components as web services on iPlanet 6.0 app server?

    My task - my company has several legacy PowerBuilder applications that access a variety of Sybase and MS SQL databases. Rather than re-inventing the wheel by re-writing these applications in Java, we would like to enable these applications to call java components (EJBs) that will provide new functionality. I would need a piece of software called CSXtend (from www.cynergysystems.com) to allow PowerBuilder to call a web service. However, I am not sure how to expose my business functions (EJBs) as web services on the iPlanet 6.0 App server. Thanks for all previous responses! Any additional info would be greatly appreciated! Mike

    I have used Glue (http://www.themindelectric.com/products/glue/glue.html) to expose some of our stuff as Web Services. I recently found this on serverside. It's pretty good.
    http://www.theserverside.com/resources/article.jsp?l=Systinet-web-services-part-1
    I believe that the middleware they use can be plugged into IPlanet. There is also an article in the knowledge base on the IPlanet site.
    Jon

Maybe you are looking for