Book Section
-----
TY JavaScript 3rd Ed.
Teach Yourself JS 1.5
Teach Yourself DHTML
Teach Yourself JS 1.3
LLWW: JavaScript

General Section
-----
Discussion Forum
Articles / Tips
JavaScript Links
About the Author
Privacy Policy
Contact Me



Other Sites
-----
Website Workshop
JavaScript Weblog

JavaScript Workshop Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Problem with a sentence

 
Post new topic   Reply to topic    JSWorkshop Forum Index -> JavaScript
View previous topic :: View next topic  
Author Message
REDONDOS
New member
New member


Joined: 01 Aug 2002
Posts: 2

PostPosted: Thu Aug 01, 2002 2:52 pm    Post subject: Problem with a sentence Reply with quote

Hello, this is my first post and I'm practically a newbie, the question is:

What does this do?

Code:
y = 1+(x<<8);


I don't know what "<<" means... can you help me out?

Thanks.
REDONDOS
Back to top
View user's profile Send private message
mgm
Site Admin
Site Admin


Joined: 13 Jul 2002
Posts: 304
Location: Salt Lake City, UT

PostPosted: Fri Aug 02, 2002 4:01 am    Post subject: Reply with quote

The << is a binary shift operator. Here's Netscape's description of what that means:
Quote:
(Left shift) Shifts its first operand in binary representation the number of bits to the left specified in the second operand, shifting in zeros from the right.


1<<8 is 256, 2<<8 is 512, 0<<8 is zero, and if that makes no sense at all you'll need to learn a bit of binary arithmetic before it will.

I've never had occasion to use binary math in JavaScript, but I'm sure there's a point to it sometimes.
_________________
Michael Moncur
Owner and Moderator, The JavaScript Workshop
Read the guidelines before posting: http://www.jsworkshop.com/posting.html
Back to top
View user's profile Send private message Send e-mail Visit poster's website
REDONDOS
New member
New member


Joined: 01 Aug 2002
Posts: 2

PostPosted: Fri Aug 02, 2002 2:11 pm    Post subject: Reply with quote

Thanks a lot, man, understood it perfectly.

Where can I read more about binary arithmetic?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    JSWorkshop Forum Index -> JavaScript All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
(c) 1997-2002 Starling Technologies and Michael Moncur. Portions (c) Sams Publishing.