How do you Invert signed numbers?

Hi there.
A simple question: How can I invert the sign of an integer? ie) convert -12 to +12? No doubt there is a really simple way to do this, but I'm stumped, I cannot find anything and I've been working on this program all day.
I'll be very grateful to anyone who can let me know if Java provides a way to do this, or point me in the right direction if it takes some tweaking of binary numbers using the Math package or something.
Cheers!

sabre150 wrote:
paul.miner wrote:
n = -n
Not obscure enough! I prefer
int n = ....;
n = (0xffffffff ^ n) + 1;
Bah, that +1 operation is way too clear; better make that:
n^= 0xffffffff;
int m;
for (m= 1; m != 0 && ((n&m) != 0); m<<= 1);
n|= m;
if (m == 0) n= m;
else for (m >>= 1; m != 0; n^= m, m>>=1);kind regards,
Jos ;-)

Similar Messages

  • How do you suppress page numbers. I am trying to print a screenplay for the first time since switching to Pages and I can't suppress Page

    How do you suppress page numbers. I am trying to print a screenplay for the first time since switching to Pages and I can't suppress Page #1 without making the rest of the pages inaccurate, as page #1 is the Title Page. Does anyone have any suggestions?

    When you signed to be able to post in the forums, you were urged to read and accept the Terms of Use ruling these forums.
    They claim :
    The contents of the "More Like This" box prove that applying the rules you would have get the wanted explanations without creating this new thread.
    Yvan KOENIG (VALLAURIS, France) mardi 26 avril 2011 10:04:03

  • How do you call 0900 numbers on iphone?

    how do you call 0900 numbers on iphone? it keeps saying that i cant call it- is there a code or anything?
    im on vodafone
    thanks

    thanks for the advice both
    ive noticed though that sometimes companies provide a cheaper alternative to an 0900 number as in 8***** or something - if this makes any sense? but even those numbers are still blocked???

  • HT1349 just got a new iphone. How do you transfer phone numbers from an old iphone to a new one

    How do you transfer phone numbers from a 3gs to a 4s?

    PLug your 3gs into iTunes, in the left panel right click on your iPhone and create a backup. After the back up is complete plug your 4s into iTunes, right click on it in the left panel and select restore from backup, select the backup file from your 3gs and that should load everything from your 3gs to your new iphone
    http://support.apple.com/kb/HT2109

  • How do you add minimal numbers in a loan form?

    How do you add minimal numbers in a loan form as in: http://screencast.com/t/KcE65bHCG?

    Hi Andy,
    You can define the amount in the webform field. You need to make changes in the HTML of the form as mentioned in this article : http://kb.worldsecuresystems.com/kb/collect-payment-using-form.html#modify-amount
    Hope this helps.
    Cheers,
    Aishvarya Raj Rastogi

  • How do you make mobile numbers the default number used in your contacts for sending text?

    How do you make mobile numbers the default number used in your contacts for sending text?

    Go to your contacts, find the contact that you wish to text, hit 'edit', and move that contact's numbers around until the mobile number is at the top. Arduous I know, but it works. Now when you go to text that person, the mobile number should be the default.
    Best.

  • How do you start endnote numbering over in each section?

    How do you start endnote numbering over in each section?

    Breaking the threads between sections won't help you, since the endnotes
    and the endnote references in the text are completely static, regular
    text. (However, if this is a long document, breaking the thread between
    sections/chapters can significantly speed up InDesign, and it's one of
    the first things I do when working on long docs.)
    Now, presumably your endnotes references in the text have a character
    style applied to them? Likewise, hopefully your endnote references at
    the beginning of each endnote also have a character style applied to
    them? If not, the first thing to do is apply a char style to these (make
    2 styles -- one for the refs in text, the other for the numbers at start
    of endnotes).
    Next, is to find a script that can do maths based on a character style.
    Must be one around somewhere...  ... yup, here
    you go:
    http://indesignsecrets.com/free-script-to-change-all-numbers-in-a-document-using-math.php
    So, now you just need to run the script, figure out how much to subtract
    from each character style for each section so that the first note is 1,
    and Bob's your uncle.

  • How do you insert page numbers into a pdf that combines multiple documents?

    I need to combine a number of documents into one PDF that then has correct pagination for the whole new document. How do you insert page numbers when combining into one PDF?

    Hi,
    You can go to Tool panel. Go to Pages. Click on Header& Footer -->  Add & Footer from the Add Header and Footer
    Regards,
    Ajlan Huda.

  • How do you open a Numbers file sent from another Mac user with same operating system, i get a pop up that says I'm missing an index.hml file??? HELP PLEASE

    how do you open a Numbers file sent from another Mac user with same operating system, i get a pop up that says I'm missing an index.hml file??? HELP PLEASE

    The operating system may be the same but the Numbers applications are likely different.  You need to get the apps in sync.  Unfortunately, the Numbers (and Pages as well) saga is pretty confusing (and frustrating).  Here's some info from the iWork resident version expert (PeterBreis0807):
    Pages '09/'08 can not open Pages 5 files and you will get the warning that you need a newer version.
    Pages 5.2 can open Pages '09 files but may damage/alter them. It can not open Pages '08 files at all.
    Older versions of Pages 5 can not open files from later versions of Pages 5.
    Once opened and saved in Pages 5 the Pages '09 files can not be opened in Pages '09.
    Anything that is saved to iCloud and opened in a newer version of Pages is also converted to Pages 5 files.
    All Pages files no matter what version and incompatibility have the same extension .pages.
    Pages 5 files are now only compatible with themselves on a very restricted set of hardware, software and Operating Systems and will not transfer correctly on any other server software than iCloud.
    Apple has removed almost 100 features from Pages 5 and added many bugs.

  • How do you create sequential numbered labels ?

    How can I create sequentially numbered labels with pages?

    Would be useful to know if you are asking about labels whose contents is the same except the number or if the main part of the label is also variable.
    In second case what's the source of the datas ?
    Yvan KOENIG (VALLAURIS, France) jeudi 15 septembre 2011 17:02:27
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community

  • How do you format a numbers file that has been sent from excel?

    I have a report card that I have sent from a PC using excel to my air mac numbers program.  It sent it in four parts.  How do I format this?

    Denise,
    Select the cells, click the format icon to open the format panel, choose the cell tab and pick the format that you want to apply.
    Jerry

  • How do you print the numbers next to the first column

    In Numbers I can't figure out how to print the numbers next to the first column to the left. Say I have 350 people on a list and I want to print the sheet with the numbers next to the people's name, how do I do that. Excel automatically does it. However, I cannot find the option to print and include the numbers from the standard Numbers worksheet. Thanks for your assistance.

    In excel it is actually in the page setup dialog. under the "sheet" tab. Numbers doesn't have one table per page (excel is basically one large table of cells). So printing header and column labels doesn't really work in numbers, because those labels don't show up until you click inside the tables. If you notice when you do that they abstruct the view of everything else that might be near the edge of the table.
    The other posters response is the best way to do it. you can get column Numbers (but not letters) by using the column command in an extra row at top also. Thre is a way if you really want column letters, but it ain't pretty. Let us know if you want that too.
    Jason

  • How do you customize page numbering?

    I'm trying to number a document 1, 1b, 2, 2b, 3, 3b, etc.
    How can I adjust the page numbering so that this will automate and I wont have to manually adjust the numbering for every other page?

    You don't. ID can number 1, 1b, 3, 3b... through some previous page number marker trickery, but unless you restart numbering using the section and numbering options on each spread there's no way to get the intervening numbers and still have independent pages. You might get away with creating a full spread on one double-width page, then place that into a true facing pages document for imposition and printing, but I wouldn't guarantee that will work.
    Another option is to make a number list and place it as a text file once your document is finished.

  • How do you sort in numbers

    Can anyone tell me how to sort colums or rows in Numbers?  It appears to me Apple has made a Spreadsheet that can not sort columns and rolls.  If it is possible I apoligize to Apple, but so far I have not found any way. 
    Thanks for any help.

    Hi Jeldee,
    Sorting is easy in Numbers 3. You click the triangle by the column letter and choose your sort.
    If, in this example, you wanted the data sorted first by Author, and within that by Copyright, and then by Title, all you have to do is sort by the Title column first, then sort by the Copyright column, and then finally by the Author column.
    SG

  • How do you invert an object's position in Edge Animate?

    How can the position of an object in a scene define the position of another object in the same scene?
    Essentially, if Object A had a position of x=100 y=100, What code would I need to write to make Object B have a position of x=-100 y=-100?
    I would like to move Obbject A around freely and have object B always be an exact inverted position. Is this possible? How?
    Thanks in advance.
    -Stephen

    Which version of CC and have you install the updates?
    Supply pertinent information for quicker answers
    The more information you supply about your situation, the better equipped other community members will be to answer. Consider including the following in your question:
    Adobe product and version number
    Operating system and version number
    The full text of any error message(s)
    What you were doing when the problem occurred
    Screenshots of the problem
    Computer hardware, such as CPU; GPU; amount of RAM; etc.

Maybe you are looking for

  • Prem El 7: Previewing individual video tracks

    Hi All, I am new to Prem Elements 7 and have been spending a lot of time on my first project. Some simple things are holding me up and I can't resolve with the Help centre. I have 3 video tracks stacked in the timeline. A key problem is how to select

  • BAPI for changing parked documents

    Hi , I need to know any BAPI exist for changing the posting date of the parked documents. Please let me know if there are any BAPI's Thanks

  • Variables in Authorizations

    Hello Gurus,        I hope you can help me with a problem. We use BI7 and at the moment we have 3 authorisation relevent objects Sales Office, Cost Centre and Sold To. We load this data via spreadsheets for each user, some will have a * and some will

  • Photoshop *.RAW format

    Can someone tell me the difference between Photoshop's PSD format and Photoshop's RAW format. This format is located in the formats dropdown as an option when saving. 1. Does the RAW format have a larger gamut than the PSD format? 2. If I export to a

  • Display an image on button click?

    Hi, I'm using Captivate 3 and trying to set up an image to be displayed in a certain position on the screen when a button is clicked. It would always be on the top layer to overlay anything else on the screen at the time. I need to do this for multip