PDA

View Full Version : i need your help


ghost
03-06-2003, 07:55 PM
hello
i want someone explain to me this
x=x<<0
x=x<<2
x=x<<9
and what is the function of this
n = parseInt(n,16)
please explain to me how it is work***parseInt()***

Jason
03-06-2003, 09:55 PM
parseint( string, int) where string is the string you are going to be checking and the int will be a value for say in your case 16 you will be finding base 16 of the number in the string n. Had you just done parseInt(string) you would be given the first number found in the string.

Jason

ghost
03-06-2003, 10:23 PM
thank you Jason
can you give me an exemple
and you don't explain to me that
x=x<<0
x=x<<2
x=x<<9

GoHF
03-07-2003, 02:53 AM
I think the below is an example enough for parseInt.


x = "10apples";
decimal = parseInt(x); // decimal = 10;
hexa = parseInt(x,16); // hexa = A. A is 10 in base 16 (hexadecimal)


As for the << operator it is the "Bitwise Left Shift" operator. Find more about it at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsoprlshift.asp

ghost
03-07-2003, 01:39 PM
thank you a lot:thumbsup:

Roy Sinclair
03-07-2003, 10:01 PM
Note a SERIOUS and subtle error exists in the example code (fix is highlighted in red):

Originally posted by GoHF
I think the below is an example enough for parseInt.


x = "10apples";
decimal = parseInt(x,10); // decimal = 10;
hexa = parseInt(x,16); // hexa = A. A is 10 in base 16 (hexadecimal)


As for the << operator it is the "Bitwise Left Shift" operator. Find more about it at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/js56jsoprlshift.asp

If you leave off the base for decimal numbers then you'll get octal or an error if the user happens to put a leading zero on the number. You won't believe how often this unexpected behavior messes people up.