Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

confusion 1

Status
Not open for further replies.

theEclipse

Programmer
Dec 27, 1999
1,190
US
I have noticed some things that I am not sure about. can you tell me what they do?

**-the second operator in the parseInt() function:
parseInt('102983',10).

also, does this crossover to the parseFloat function?

**-the % operator:
n % 10

I think that this might be kind of like divide, but with no remainder, if so, is there a function that returns only the remainder?


thankyou
theEclipse
eclipse_web@hotmail.com
**\\||It was recently discovered that research causes cancer in rats||//**
 
hi :)
the parseint second arg is to set the base (radix) - there is a thread on this subject somewhere but i can't find it ! the point is that if you don't set this to 10, you might have some surprise (here is what they say in devedge : If the radix is not specified or is specified as 0, JavaScript assumes the following: If the input string begins with "0x", the radix is 16 (hexadecimal). / If the input string begins with "0", the radix is eight (octal). / If the input string begins with any other value, the radix is 10 (decimal).
about the %, here is what devedge say - oh and there is not function to get the reminder : The modulus operator returns the first operand modulo the second operand, that is, var1 modulo var2, in the preceding statement, where var1 and var2 are variables. The modulo function is the integer remainder of dividing var1 by var2. For example, 12 % 5 returns 2
 
thanks
theEclipse
eclipse_web@hotmail.com
**\\||It was recently discovered that research causes cancer in rats||//**
 
wait, then does 8 tell javascript to look for octal? theEclipse
eclipse_web@hotmail.com
**\\||It was recently discovered that research causes cancer in rats||//**
 
thanks again theEclipse
eclipse_web@hotmail.com
**\\||It was recently discovered that research causes cancer in rats||//**
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top