- Home /
Is there something like the parseInt function for doubles?
I am using the parseInt and parseFloat functions, but I am also working with doubles. I have tried typeing parseDouble but that is not a function according to unity so I need something that does the same thing as parseInt and parseFloat does but for doubles. Here is an example of the code I am trying to work with. The parseDouble does not work but if everything in this example that is double is made float or int then it works(assuming I'm working with floats or ints), but with doubles it does not work.
var arr = new Array ();
for(var i= 0; i < newDataParsed["data"].length; i++){
arr.Push (newDataParsed["data"][i][key4]);
}
var builtinArrayDouble : double[] = new double[arr.length];
for(var v = 0; v < arr.length;v++){
builtinArrayDouble[v] = parseDouble(arr[v]);
}
Any ideas? Thanks.
Answer by Loius · Jan 07, 2013 at 09:53 PM
Yep: Don't use Array. Ever.
Use ArrayList instead - it's literally better in every way, and it has all the same functions, and it's typed so you don't have to cast it around.
var arr : ArrayList.XYZ = new ArrayList.XYZ();
Replace XYZ with "less than symbol" double "greater than symbol".
That said, I don't know of a Double version of parseX. I believe I've used "doubleVar = floatVar + 0.0" as a sort of force-conversion before.
Your answer
Follow this Question
Related Questions
What's wrong with this code? 1 Answer
Loading function into array using GameObject.Find 1 Answer
Arrays and indices issues 1 Answer
Calling A Function Once 0 Answers