Results 1 to 6 of 6
Thread: " shift " Operator ???
- 02-08-2009, 09:24 AM #1
Senior Member
- Join Date
- Jan 2009
- Posts
- 119
- Rep Power
- 0
" shift " Operator ???
Salamu Alaikum ala muslimeen,
Hello there!!!
I read something about the shift operator. I understood that it's faster than some of the operators in java like multiplcation, Math.pow, and division.
Would someone explain to me what the operator does? and how (if possible) you can use it in place of the other operators???
- 02-08-2009, 03:54 PM #2
bit shifting
Here's a link that expalins a little:
Bitwise and Bit Shift Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)
Some links with samples:
SCJP Tip Line - Bit Shifting
Java Notes: Bitwise Operators
In the last link there's an interesting comment:
Luck,On some older computers it was faster to use shift instead of multiply or divide.
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 02-08-2009, 06:27 PM #3
Senior Member
- Join Date
- Sep 2008
- Posts
- 564
- Rep Power
- 5
also note that shifting would only be considered fast if multiplying/dividing by powers of 2. doing anything more would be impractical but would make for a nice exercise.
- 02-08-2009, 07:00 PM #4
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5
It is faster on any computer, unless your compiler has an optimizer. It's only a few nanoseconds though...
I die a little on the inside...
Every time I get shot.
- 02-09-2009, 05:47 AM #5
Senior Member
- Join Date
- Jan 2009
- Posts
- 119
- Rep Power
- 0
got it :)
The link from CJSLMAN helped alot!!!
- 02-09-2009, 05:51 AM #6
Senior Member
- Join Date
- Jan 2009
- Posts
- 119
- Rep Power
- 0
Similar Threads
-
Java, Military Format using "/" and "%" Operator!!
By sk8rsam77 in forum New To JavaReplies: 11Last Post: 02-26-2010, 03:03 AM -
MoneyOut.println("It took you (whats wrong?>",year,"<WW?) years to repay the loan")
By soc86 in forum New To JavaReplies: 2Last Post: 01-24-2009, 06:56 PM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM -
<core:forEach var="" begin="+<%=j%>+">???
By freddieMaize in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 09-27-2008, 01:20 AM -
"Jumble" or "Scramble" Program
By Shadow22202 in forum Java AppletsReplies: 8Last Post: 04-30-2008, 03:42 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks