- Home /
Question by
twoface262 · Dec 14, 2012 at 04:32 AM ·
javascriptstringint
int.parse with decimal?
How would I turn a string "101.123" into a int? I try to use int.parse with it, but it's giving me this error saying that it can't parse the string.
Comment
Best Answer
Answer by Eric5h5 · Dec 14, 2012 at 04:59 AM
A couple of possibilities:
var myString = "101.123";
var myInt = parseInt (parseFloat (myString));
Or
var myString = "101.123";
var myInt = parseInt (myString.Substring (0, myString.IndexOf (".")));
Your answer
Follow this Question
Related Questions
How to convert a string to an int? 1 Answer
Sending a string via email from Unity? 2 Answers
converting "int" to "string" 2 Answers
change .color on contact 1 Answer
Random int Value 3 Answers