Jul 25, 2002 #1 theme Technical User Sep 5, 2006 2 KE what's the java command for making a number out of a string " 42 " -> 42 ?
Jul 25, 2002 #2 Turkbear Technical User Mar 22, 2002 8,631 US Hi, Try num = parseInt("42" or decnum = parseFloat("43.25" Upvote 0 Downvote
Jul 25, 2002 #3 trollacious Programmer Sep 29, 2004 4,046 US Just to be safe, use: parseInt('42', 10); which converts to decimal. If you use any number starting with a '0', then parseInt will see that as as octal number. By default, parseInt('042'); equals 34 in decimal. Another way to convert a string to numeric value is to just multiply by 1. Upvote 0 Downvote
Just to be safe, use: parseInt('42', 10); which converts to decimal. If you use any number starting with a '0', then parseInt will see that as as octal number. By default, parseInt('042'); equals 34 in decimal. Another way to convert a string to numeric value is to just multiply by 1.