Results 1 to 3 of 3
- 09-27-2012, 08:48 PM #1
Flip int value(1234 becomes 4321)
Is there a fast way to flip an int? For example:
This could be done by converting it to a string and reverse it. But it is a very inefficient and expensive way to do it. Is there any faster way?Java Code:int i = 1234; System.out.println(flipInt(i)); //4321
Like with bit shifting?
- 09-27-2012, 11:43 PM #2
Re: Flip int value(1234 becomes 4321)
Look at using the %, /, + & * operators
Last edited by Norm; 09-27-2012 at 11:47 PM.
If you don't understand my response, don't ignore it, ask a question.
-
Re: Flip int value(1234 becomes 4321)
Careful though.
What is the result of flipping 1230?
what the result from the flip above -- what about 321?
Should it result in 123? 1230? 12300?
Similar Threads
-
Flip Pictures on DrJava
By siddanth1 in forum New To JavaReplies: 2Last Post: 02-10-2012, 02:08 AM -
coin flip program
By chandrasekhar.melam in forum New To JavaReplies: 5Last Post: 09-26-2011, 05:30 PM -
How to Copy and Flip a Picture Horizontally
By tecnicamente in forum New To JavaReplies: 1Last Post: 05-11-2011, 01:47 AM -
Othello/Reversi flip checkers
By chielt in forum Java AppletsReplies: 10Last Post: 01-02-2010, 11:25 PM -
Random coin flip application
By Boomer1 in forum New To JavaReplies: 8Last Post: 12-18-2009, 02:57 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks