Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old June 11th, 2005, 04:57 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
javascript integer

how could I convert an variable:

var a = '1';

into integer.

so when I do

a = a + 1;

I get 2 not 11;

(i must have '' in variable!)

Reply With Quote
  #2  
Old June 12th, 2005, 10:52 AM
lmz lmz is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 79 lmz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: javascript integer

i don't know if this iz uzefull:


parseInt
Function. Parses a string argument and returns an integer of the specified radix or base.

Syntax
parseInt(string [,radix])
Parameters
string is a string that represents the value you want to parse.
radix is an integer that represents the radix of the return value.


Implemented in
Navigator 2.0
Navigator 3.0: returns "NaN" on all platforms if the first character of the string specified in parseInt(string) cannot be converted to a number. In previous releases, it returned "NaN" on Solaris and Irix and zero on all other platforms.
Description
The parseInt function is a built-in JavaScript function. It is not a method associated with any object, but is part of the language itself.
The parseInt function parses its first argument, a string, and attempts to return an integer of the specified radix (base). For example, a radix of 10 indicates to convert to a decimal number, 8 octal, 16 hexadecimal, and so on. For radixes above 10, the letters of the alphabet indicate numerals greater than 9. For example, for hexadecimal numbers (base 16), A through F are used.

If parseInt encounters a character that is not a numeral in the specified radix, it ignores it and all succeeding characters and returns the integer value parsed up to that point. parseInt truncates numbers to integer values.

If the radix is not specified or is specified as zero, 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).
If the first character cannot be converted to a number, parseInt returns "NaN".
For arithmetic purposes, the "NaN" value is not a number in any radix. You can call the isNaN function to determine if the result of parseInt is "NaN." If "NaN" is passed on to arithmetic operations, the operation results will also be "NaN."


Examples
The following examples all return 15:

parseInt("F", 16)
parseInt("17", 8)
parseInt("15", 10)
parseInt(15.99, 10)
parseInt("FXX123", 16)
parseInt("1111", 2)
parseInt("15*3", 10)
The following examples all return "NaN":

parseInt("Hello", 8)parseInt("0x7", 10)parseInt("FFF", 10)
Even though the radix is specified differently, the following examples all return 17 because the input string begins with "0x."

parseInt("0x11", 16)parseInt("0x11", 0)parseInt("0x11")

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > javascript integer


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT