Freelancers Network
 
skill list top cap
Homepage
Join the Freelancer's Network
Update your details
Find a freelancer
Post a project
Find a project
Projects Archive
Post a job
Find a job
Jobs Archive
See Dan's Pages
See Andy's Pages
Link to this site
Resources
Join/Leave Forum
Forum Messages
+Additions+ Adverts
Advertising
Contact Us
Subscribe to our newsletter - enter your email address and hit return
Freelancers.net is owned and operated by Andy Stowell and Dan Winchester
skill list end cap
guru web hostcom

Find me again on Freelancers.net

RE: FN-FORUM the operator >>

date posted 15th January 2002 16:09

The answer is below

Shift operators
The shift operators also manipulate bits. They can be used solely with
primitive, integral types. The left-shift operator ( < > ) produces the operand to the
left of the operator shifted to the right by the number of bits specified
after the operator. The signed right shift > > uses sign extension: if the
value is positive, zeroes are inserted at the higher-order bits; if the
value is negative, ones are inserted at the higher-order bits. Java has also
added the unsigned right shift > > > , which uses zero extension: regardless
of the sign, zeroes are inserted at the higher-order bits. This operator
does not exist in C or c++.
If you shift a char, byte, or short, it will be promoted to int before the
shift takes place, and the result will be an int. Only the five low-order
bits of the right-hand side will be used. This prevents you from shifting
more than the number of bits in an int. If you're operating on a long,
you'll get a long result. Only the six low-order bits of the right-hand side
will be used so you can't shift more than the number obits in a long.
Shifts can be combined with the equal sign ( «= or »= or »>=). The lvalue is
replaced by the lvalue shifted by the rvalue. There is a problem, however,
with the unsigned right shift combined with assignment. If you use it with
byte or short you don't get the correct results. Instead, these are promoted
to int and right shifted, but then truncated as they are

Regards

Darren Spink

http://www.arkad.co.uk

Tel: +44(0)113 253 4750
Fax: +44(0)113 253 1686
ICQ: 56667649
-----Original Message-----
From: [EMAIL REMOVED]
[EMAIL REMOVED] Behalf Of marco polo
Sent: 15 January 2002 09:19
To: [EMAIL REMOVED]
Subject: FN-FORUM the operator >>


hi there,
i don't know where to ask this question in java newsgroups and i hope this
mailing list will help.
i'm a java newbie and have frequently come across codes like this:
int r=(colorval >> 16) & 0xff;
int g=(colorval >> 8) & 0xff;
int b= colorval & 0xff;
can anybody here explain how this operator work?
marco



Send and receive Hotmail on your mobile device: Click Here
============================================================ * Free listing
for freelancers * Free to advertise jobs * Free jobs distribution service *
Free database of 5000 freelancers Freelancers and Freelance Jobs:
http://www.freelancers.net Forum FAQs: http://freelancers.netrickery.com To
unsubscribe please email:
[EMAIL REMOVED] If you have
difficulties unsubscribing please email: [EMAIL REMOVED]




Messages by Day
January 31st 2002
January 30th 2002
January 29th 2002
January 28th 2002
January 27th 2002
January 26th 2002
January 25th 2002
January 24th 2002
January 23rd 2002
January 22nd 2002
January 21st 2002
January 20th 2002
January 19th 2002
January 18th 2002
January 17th 2002
January 16th 2002
January 15th 2002
January 14th 2002
January 13th 2002
January 12th 2002
January 11th 2002
January 10th 2002
January 9th 2002
January 8th 2002
January 7th 2002
January 6th 2002
January 5th 2002
January 4th 2002
January 3rd 2002
January 2nd 2002
January 1st 2002


Messages by Month
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002


Messages by Year
2008
2007
2006
2005
2004
2003
2002
2001
2000