The Shift operator Question

Dear sir/madam
I having question for the shift operator.
What different between >>> and >> ?
I have refer to sun tutorial, it state >>> is unsign, what does it mean?
and last is
if integer is 13
what anwer for 13>>8
is it move for 8 right by position? pls told me in detail
is it answer same with the 13>>>8 ?
Thanks for ur solutions

You can play with the following for a while.
final public class BinaryViewer{
  final static char[] coeffs = new char[]{(char)0x30,(char)0x31};
public static String toBinary(int n) {
  char[] binary = new char[32];
  for(int j=0;j<binary.length;j++) binary[j]=(char)0x30;
  int charPointer = binary.length -1;
  if(n==0) return "0";
  while (n!=0){
      binary[charPointer--] = coeffs[n&1];
      n >>>= 1;
return new String(binary);
public static void print(int n){
    System.out.print(BinaryViewer.toBinary(n));
    System.out.print("   ");
    System.out.println(String.valueOf(n));
public static void main(String[] args) throws Exception{
   int n=Integer.MIN_VALUE;//Integer.parseInt(args[0]);
   int m=Integer.MAX_VALUE;//Integer.parseInt(args[1]);
   BinaryViewer.print(n);
   BinaryViewer.print(n>>8);
   BinaryViewer.print(n>>>8);
   System.out.println();
   BinaryViewer.print(m);
   BinaryViewer.print(m>>8);
   BinaryViewer.print(m>>>8);
  System.out.println();
    n=1024;
    m=-1024;
   BinaryViewer.print(n);
   BinaryViewer.print(n>>8);
   BinaryViewer.print(n>>>8);
   System.out.println();
   BinaryViewer.print(m);
   BinaryViewer.print(m>>8);
   BinaryViewer.print(m>>>8);
  System.out.println();
   n=2048;
   m=-2048;
   BinaryViewer.print(n);
   BinaryViewer.print(n>>8);
   BinaryViewer.print(n>>>8);
   System.out.println();
   BinaryViewer.print(m);
   BinaryViewer.print(m>>8);
   BinaryViewer.print(m>>>8);
  System.out.println();
}

Similar Messages

  • Shift Operation in Prodcution order.

    How to record the shift operation in the Production order?

    Hi,
    Please try to simply your subject of posting. It is not necessary your subject and body of discussion should be same.
    Yes possible to remove under SQL management studio provided you have authorization to access.
    Thanks & Regards,
    Nagarajan

  • How can I do Shift operation in plsql

    hello,
    i want to know whether there is any package or operator to do the shift operation in plsql.
    like (myVar<<8 in c++).

    why don't you use
    myvar := mywar * power(2,8);

  • Question about the conitional operator

    Hello! This may be a dumb question, but I still don't know the answer! =D
    I know the conditional operator is an operator and not a statement, and I was reading a site http://sophia.dtp.fmph.uniba.sk/javastuff/javacourse/week2/16.html that said this works:
    name.equals("Rumpelstiltskin") ? give_back_child() : laugh();
    which I guess makes sense. But when I tried to compile a code just like this, it complains it's not a statement
    What am I doing wrong?

    Ah okay... So you always need a LHS for the conditional operator? I thought that in this case, since a function is being called, then the function is the statement. Sorta like:
    if(a == b)
      doThis();
    else
      doThat();So I have to store the result of a == b in c, for example, if I wanted to use the conditional operator? Even though "c" would be of no use to me whatsoever?

  • Hi All, I have question about the iMac operating system. I have the last updated. The problem when I manage the place of the folder windows they are all mixing up. I mean they not on the place where I left them. how to set they stay on the same place. Tks

    Hi All, I have question about the iMac operating system. I have the last updated. The problem when I manage the place of the folder windows they are all mixing up. I mean they not on the place where I left them. how to set they stay on the same place? I know there are different possibilities to set.
    I tried but it not helped for me. What I can do? How and where can set this they stay on their place?
    Thanks.
    laci

    Option 1
    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild. Choose to Repair Database. If that doesn't help, then try again, this time using Rebuild Database.
    If that fails:
    Option 2
    Download iPhoto Library Manager and use its rebuild function. (In Library Manager it's the FIle -> Rebuild command)
    This will create an entirely new library. It will then copy (or try to) your photos and all the associated metadata and versions to this new Library, and arrange it as close as it can to what you had in the damaged Library. It does this based on information it finds in the iPhoto sharing mechanism - but that means that things not shared won't be there, so no slideshows, books or calendars, for instance - but it should get all your events, albums and keywords, faces and places back.
    Because this process creates an entirely new library and leaves your old one untouched, it is non-destructive, and if you're not happy with the results you can simply return to your old one. 
    Regards
    TD 

  • The Welcome to the X1 Operating System opening screen question

    I got a new X1 box today and went to install it and the screen seems to be stuck at the "Welcome to the X1 Operating System" screen.  How long should this screen be on for before it advances in the installation process?  My box also says boot and that is not changing as well.  What should the box say?

    Yes, the new box is hooked up in the exact same place where the old one was. Trust me, I have unplugged it many times. I have a technician coming out tomorrow.

  • TS2570 Hi I had a question, it is that when I pressed the shift-command-V, it became black , numbers and letters kept coming and then stopped. Last thing said is calling register service

    So I tried everything even the shift-command-V thing it has been on for about 10 min and nothing changed. Please help

    Take it to your local Apple Store or AASP, it's covered by a 1 year hardware warranty. If you have AppleCare then give them a call but I'm pretty sure they will advise the same. If you have not purchased AppleCare yet please do, this will extend the warranty to 3 years however it MUST be purchased within the first  year of ownership. Let it go 366 days and you are out of luck. AppleCare will also include telephone support too.
    Good luck.

  • JAVA (SHIFT OPERATOR)

    Hi,
    I really want to know SHIFT operator in Java like >> , << , >>>
    Could anybody kindly help to explain??
    And
    byte a =-1;
    a = (byte)(a>>>2);
    why the output become -1??
    thanks.

    umm i did get them mixed up. preserved sign bit right shift is >>, pulling-zeros is >>>. so keep that in mind. (ie, 18>>2 == 10010>>2 == 11100 which is -4)
    To calculate the resulting number from >>> right shifts, check this: http://www.janeg.ca/scjp/oper/shift.html
    In response to your original question, it seems it's far more complicated than I at first thought. The -1 that you're getting is an odd (and rather interesting, imo) byproduct of modular arithmetic. what you wrote is exactly similar to this code (ie, my code mimics the castings that happen in your code):
            byte a = -1;
            int b = (int) a;
            int c = b>>>2;
            byte d = (byte) c;
            System.out.print(d);So what happens is A, which is a string of ones (ie 11111111) is casted to an int, B. In general, casting a byte to an int returns an int with exactly the same bits at the end with the sign bit repeated 24 times at the start (ie, 01101011-->(int)0000...00001101011). So B is 11111111111111...1111 (32 ones). Then we right shift B by 2 (we'd get the same answer right shifting it by 0, 1, 2, etc, all the way up to (and including) 24). Then we recast the int C to a byte. This is where the interesting thing happens: Depending how much we right shifted B to get C, C will be a certain number of zeros (call this Z) followed by (32-Z) ones. Apparently, in (mod 2^8) in two's complement all of these numbers are congruent to -1, so the cast gives negative one.
    (remember that the int 127 cast to byte is 127, while the int 128 cast to byte is -128. conversions to a lower-bit type always happen mod 2^N, where N is the number of bits in the type we're casting to.)
    BTW, thanks for this problem. i had a fun half hour figuring it out. hopefully it made some sense to you...
    (EDIT: Flounder is right--you can just view the cast from int to byte as keeping the last 8 bits. much easier to think of it that way, though my definition does give some intuitions about WHY all this works.)
    Edited by: a_weasel on Oct 13, 2008 8:00 PM

  • To download an App the 3 security questions are required. But at the end, apple is not able to complete the task and gives an error message. No more downloads are possible. What can I do?

    to download an App the 3 security questions are required. But at the end, apple is not able to complete the task and gives an error message. No more downloads are possible. What can I do?

    Very Important, how much Free Space is on your Hard Drive first of all? Click on the Macintosh HD on the Desktop, then do a Get Info on it.
    Could be many things, we should start with this...
    "Try Disk Utility
    1. Insert the Mac OS X Install disc, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu at top of the screen. (In Mac OS X 10.4 or later, you must select your language first.)
    *Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.*
    3. Click the First Aid tab.
    4. Select your Mac OS X volume.
    5. Click Repair Disk, (not Repair Permissions). Disk Utility checks and repairs the disk."
    http://docs.info.apple.com/article.html?artnum=106214
    Then try a Safe Boot, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
    (Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive.)
    If perchance you can't find your install Disc, at least try it from the Safe Boot part onward.
    Do they launch OK while in Safe Mode?

  • SQL Azure - Intermittent The wait operation timed out

    I have a website engine which runs a few hundred "white label" sites. It's hosted on Azure with a SQL Azure Business database. Generally everything is fine - it all works and runs at a good speed.
    However, throughout the day I get maybe 40 or 50 of the error:
    System.ComponentModel.Win32Exception: The wait operation timed out
    Please don't refer me to the connectivity blog at http://blogs.msdn.com/b/sqlazure/archive/2010/03/22/9982979.aspx as this seems to refer to problems where you just can't connect. My problem is that it's fine most of the time, but I still get these
    intermittently.
    This is sometimes on the main database, but we're also using a database for sessions and this gets the errors too. Both databases are on the same server.
    I also get errors like: 
    An existing connection was forcibly closed by the remote host
    and:
    System.Data.SqlClient.SqlException: The service has encountered an error processing your request. Please try again. Error code 40143. A severe error occurred on the current command. The results, if any, should be discarded.
    and, when evil bots are hammering the site:
    System.Data.SqlClient.SqlException: Resource ID : 1. The request limit for the database is 180 and has been reached. See 'http://go.microsoft.com/fwlink/?LinkId=267637' for assistance.
    Each website can potentially have a Google footprint of around 10,000 pages. The result it that bots are hitting the sites regularly, indexing lots of pages for hundreds of sites. I also have some worker roles doing data work. The database is clearly busy!
    I am hoping to add 2 or 3 times the number of sites that I currently have to the "engine". 
    I am looking at efficiency where possible, but the sites are clearly under a fair load from bots and visitors.
    My question is, will one of the upgrades from Business to S2, P1, P2 or P3 resolve these problems? The financial cost of these database instances stagger greatly so I wouldn't want to update and find I'm left with the same problems but am paying many times
    more each month.
    Thank you in advance.

    Hello,
    For Web/Business edition database, the maximum limit of concurrent requests is 180. Beyond this limit, you will receive error.
    The Max woker threads for Standard(S2) is 100, you should upgrade your database to Permium tier.
    The concurrent requests limit of premium database varies depending on the reservation size of a premium database. For example, for P1, the max worker threads is 200.
    Reference:Azure SQL Database Resource Governance
    Azure SQL Database Service Tiers and Performance Levels
    Regards,
    Fanny Liu
    If you have any feedback on our support, please click here. 
    Fanny Liu
    TechNet Community Support

  • HT1495 I recently "held down the shift key" and created (and named) a new library, it's completely lost all my music on my iTunes ac! I still have it on my iPad, can I transfer all my iPad music from my iPad to a new iTunes ac (as I had to uninstall and i

    Ive had an iPad for a year or so, it's got tons of music on it. I recently got myself an iPhone. I read on here about how to set up a completely separate library using my same account (as my iphone couldn't possibly hold the same amount as my pad I thought it made sense!). Trouble is....as I set up a new library it asked me to name it, which I did. The trouble is now, every time I log in to iTunes it logs into the new library which is completely blank. It has of course not effected my music on my pad (phew!), I cannot find my original iTunes a/c anywhere on my pc. In desperation I tried to uninstall the iTunes off my pc, then reinstall, and log into my original a/c hoping all would be revealed thanks to the iCloud, but no.....it's blank! Is there anyway of copying (safely) all of my music and films FROM my iPad ONTO my new blank iTunes account?? Any help would be greatly appreciated!!

    The trouble is now, every time I log in to iTunes it logs into the new library which is completely blank. It has of course not effected my music on my pad (phew!), I cannot find my original iTunes a/c anywhere on my pc.
    Okay, try launching iTunes while holding down the shift key (again) but this time, click "Choose library". Browse to the location of the old library file. The default locations of the library file are inside the iTunes folder described in the following table:
    Operating System
    Default location of iTunes Folder
    Mac OS X
    /Users/[your username]/Music
    Microsoft Windows XP
    \Documents and Settings\[your username]\My Documents\My Music\
    Microsoft Windows Vista
    \Users\[your username]\Music\
    Microsoft Windows 7
    \Users\[your username]\My Music\
    Find and open the library file. Are you seeing your normal library now?

  • Error 58 The specified server cannot perform the requested operation

    Hello,
    I will try to explain the situation as brief as possible. Next to our current existing MDT environment (MDT2010 on Windows 2008 R2) we are no building a new system (MDT2013 on WIndows 2012 R2). We have multiple sites and the MDT deployment share is setup
    in DFRS share so every site is getting the same deployment information and replication is done automatically. This has been working firn for 3 years with the old system and also with the new environment it was working fine in our own subnet. But when after
    i have setup the remote MDT and WDS servers it is not working in these remote sites. The images are loading fine but for some reason the win PE is not connecting to the shares on the windows 2012 server in our site. When i manuualy connect from a remote win
    PE to our server i always get the error: system error 58 has occured. The specified server cannot perform the requested operation.
    I have been doing some troubleshooting and it seems i only got this issue when i connect from win PE 5.0 to a windows 2012 R2 server in a remote subnet.
    When i use win PE 5.0 and connect to a windows 2012 R2 share in the same subnet it connects fine. 
    When i use win PE 5.0 and connect to a windows 2008 R2 share in a remote subnet it connects fine
    When i use an older win PE and i connect to a windows 2012 R2 share in a remote subnet it connects fine
    When i use win PE 5.0 and connect to a windows 2012 R2 share in a remote subnet it does NOT connect and gives the above error
    The problem is that this problem also does not occure in Windows 7, after the machine was build by MDT and get into the OS i can connect without a problem to the windows 2012 R2 shares.
    Checking the event viewer on the 2012 R2 server that is hosting the shares i see that the following events are created:
    4624: An account was successfully logged on.
    Subject:
    Security ID:
    NULL SID
    Account Name:
    Account Domain:
    Logon ID:
    0x0
    Logon Type: 3
    Impersonation Level: Impersonation
    New Logon:
    Security ID:
    domain\username
    Account Name:
    username
    Account Domain: domain
    Logon ID:
    0x1F1FC0
    Logon GUID:
    {8e360e91-001b-c726-84a6-e7281a4bcac8}
    Process Information:
    Process ID:
    0x0
    Process Name:
    Network Information:
    Workstation Name:
    Source Network Address:
    x.x.x.x
    Source Port:
    60077
    Detailed Authentication Information:
    Logon Process:
    Kerberos
    Authentication Package:
    Kerberos
    Transited Services:
    Package Name (NTLM only):
    Key Length:
    0
    This event is generated when a logon session is created. It is generated on the computer that was accessed.
    The subject fields indicate the account on the local system which requested the logon. This is most commonly a service such as the Server service, or a local process such as Winlogon.exe or Services.exe.
    The logon type field indicates the kind of logon that occurred. The most common types are 2 (interactive) and 3 (network).
    The New Logon fields indicate the account for whom the new logon was created, i.e. the account that was logged on.
    The network fields indicate where a remote logon request originated. Workstation name is not always available and may be left blank in some cases.
    The impersonation level field indicates the extent to which a process in the logon session can impersonate.
    The authentication information fields provide detailed information about this specific logon request.
    - Logon GUID is a unique identifier that can be used to correlate this event with a KDC event.
    - Transited services indicate which intermediate services have participated in this logon request.
    - Package name indicates which sub-protocol was used among the NTLM protocols.
    - Key length indicates the length of the generated session key. This will be 0 if no session key was requested.
    5140: 
    A network share object was accessed.
    Subject:
    Security ID:
    domain\username
    Account Name:
    username
    Account Domain: domain
    Logon ID:
    0x1F1FC0
    Network Information:
    Object Type:
    File
    Source Address:
    x.x.x.x
    Source Port:
    60077
    Share Information:
    Share Name:
    \\*\Captures
    Share Path:
    \??\D:\Captures
    Access Request Information:
    Access Mask:
    0x1
    Accesses:
    ReadData (or ListDirectory)
    4634: 
    An account was logged off.
    Subject:
    Security ID:
    domain\username
    Account Name:
    username
    Account Domain: domain
    Logon ID:
    0x1F1FC0
    Logon Type: 3
    This event is generated when a logon session is destroyed. It may be positively correlated with a logon event using the Logon ID value. Logon IDs are only unique between reboots on the same computer.
    Anyone an idea why this is happening?

    Hi,
    We can refer to the following blog for MDT troubleshooting:
    http://blogs.technet.com/b/askcore/archive/2012/05/08/mdt-2010-amp-2012-my-deployment-failed-what-and-where-are-logs-i-should-review.aspx
    Best Regards,
    Vincent Wu
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

  • Opening an application while pressing the shift key

    Recently, Microsoft Word 2011 failed to open and showed the message, "Microsoft Word has encountered a problem and needs to close." I followed troubleshooting instructions on the Microsoft website. Nothing cured the problem, but creating a new user account did enable Word 2011 to open normally. That seemed to imply that "a corrupt user account" was causing the problem. I could not find any instructions about how to repair that, but at some point I came across the suggestion to "hold the shift key down and click on the Word icon in the dock." I did this and Word opened normally in my account. After this, Word opened normally without holding down the shift key. Apparently this fixed the problem.
    My question is, what does pressing the shift key do while you open an application? What's different? Why did it work? What's special about the shift key in this situation?
    Thanks.

    It may be something specific to Word/Office. Individual applications may accept different launch arguments passed to them via key combinations, such as holding the Option key when launching iTunes to invoke the option for choosing the library to use.

  • Save As operation Question

    Scenario - I have a web application that generates Excel documents that can be downloaded or opened directly. The web pages are a mixture of both ASP.NET and Classic ASP so the Excel file is actually generated as an HTML table. When a Save or Save As operation
    is done when the .xls file is downloaded a specified file name passed from the web page is used in the save operation. When you open the Excel file after saving Excel displays "The file you are trying to open "filename.xls" is in a different
    format than specified by the file extension...Do you want to open the file now?" informing me that the file is not a true xls file. When you continue with the opening the file it opens normally with no issues.
    Question or Possible issue: Taking one of these files after it has been saved to a location on the computer outside of the download folder, and perform a Save As operation to change the format to a true .xls file the theExisting File Name is not displayed in
    the File Name field. The Save as type defaults to Web Page which is understandable due to how the file is generated.
    I've tried this with actual Excel spreadsheets and the File Name field on the Save As operation is populated with the current name of the file and keeps it even if you change the Save as type.
    Main Question: Is there a setting somewhere in Excel to prevent the loss of the File Name?

    Hi,
    According to your description, the "The file you are trying to open "filename.xls" alert is from a feature called Extension Hardening, and you can find more information about it here. 
    http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/03/11/excel-2007-extension-warning.aspx
    As you said and tested, Excel will retain the current file name in file name field when we save/save as the file. It's a default behavior. I suppose that the issue may be caused by the Excel that generated by web application.
    I recommend we try the 3 workarounds:
    1. Modify the ASP.NET program and make the file change to new excel format when generated
    Please see the thread:
    http://stackoverflow.com/questions/940045/how-to-suppress-the-file-corrupt-warning-at-excel-download
    2. Use "Office Migration Planning Manager" to convert the XLS to XLSX format.
    The toolkit also contains the Office File Converter (OFC), which enables bulk document conversions from binary to OpenXML formats. 
    Overview on Technet
    Download Link
    3. Use a macro to convert batch of XLS file to XLSX file and retain the file name.
    Sample code:
    Sub ProcessFiles()
    Dim Filename, Pathname, saveFileName As String
    Dim wb As Workbook
    Pathname = "C:\Users\myfolder1\Desktop\myfolder\Macro\"
    Filename = Dir(Pathname & "*.xls")
    Do While Filename <> ""
    Set wb = Workbooks.Open(Pathname & Filename)
    saveFilename = Replace(Filename, ".xlsx", ".xls")
    wb.SaveAs Filename:=Pathname & saveFilename, _
    FileFormat:=xlExcel8, Password:="", WriteResPassword:="", _
    ReadOnlyRecommended:=False, CreateBackup:=False
    wb.Close SaveChanges:=False
    Filename = Dir()
    Loop
    End Sub
    Regards,
    George Zhao
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Error: "Could not complete the requested operation" when you start Illustrator CS2 (Windows XP)

    Hi everybody i'm nick from KL Malaysia, i having a problem with my Illustrator CS2 problem can't solved it, someone can help me?
    My problem is when i open lllustrator after load finish the file thn will come out Error: "Could not complete the requested operation", i dunno y?
    Have someone same problem with me anot? got any stion to solved it?

    Nick,
    The first thing to try is to
    a) Ctrl/Cmd+Alt/Option+Shift during startup,
    or (if a) does not work)
    b) Move the folder
    a) is easy but irreversible, b) is more thorough and reversible, so if you like your settings and do not want to destroy them in vain, use b).

Maybe you are looking for