conversion to integers

Questions and answers regarding general SQL and backend databases

conversion to integers

Postby rfleming » Sun Apr 25, 2004 5:15 pm

example:

a form field shows a value of e.g. 27
application.output (customerid) displays this as 27.0

how can i convert to an integer value?
rfleming
 
Posts: 26
Joined: Tue Feb 10, 2004 12:27 am

Postby maarten » Sun Apr 25, 2004 6:28 pm

parseInt(str [, radix]) ...between square brackets means OPTIONAL.

parseInt parses its first argument, the string str, and attempts to return an integer of the specified radix (base), indicated by the second, optional argument, radix. For example, a radix of ten indicates to convert to a decimal number, eight octal, sixteen hexadecimal, and so on. For radixes above ten, the letters of the alphabet indicate numerals greater than nine. 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. If the first character cannot be converted to a number in the specified radix, it returns "NaN." The parseInt function truncates the string to integer values.

NOTE:
Chances are you are already dealing with an integer(?) but the application.output is misleading you with it's notation (27.0)
Use:
application.output (typeof myVariable)
...to check which objectType it is.
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands


Return to SQL Databases

Who is online

Users browsing this forum: No registered users and 20 guests

cron