Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Programmer Certification (OCPJP)
left shift operator
nachiket deshpande
Ranch Hand
Posts: 114
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
help!
int x=-128
x<<1 and (byte)x<<1 gives -256
-128=1111111 11111111 11111111 10000000
left shift one bit will give
11111111 11111111 11111111 00000000
how truncating it to byte gives -256
Rick Zhong
Greenhorn
Posts: 10
posted 22 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi, nachiket,
try this: (byte)
(
x<<1
)
,then you will know what is going on here.
hope this help
Rick
Who knew that furniture could be so violent? Put this tiny ad out there to see what happens:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
octal/hex/binary/unicode ?
bitwise operator question
The Shift Operators
>>> operator
Left shift problem
More...