First I use an array to enter a string of numbers as a string, like a calculator (with tempNum.Add(number.ToString()))
Then I convert it to a numerical string (with parseFloat(tempNum.Join(“”)).ToString(“n2”) so it adds comma’s and up to 2 decimal places")
Everything works great, but when I hit 10,000,000 it starts rounding, and I don’t want that.
So if I type 1764895 it correctly displays 1,764,895
But as soon as I type 1 more number it rounds the 5 (to a six if greater than five)
So if I add an 8, it will display 17,648,960 and every number after that will display 0. When I look at the number in the inspector it has the correct, non-rounded number. Does anyone know why or how to solve it?
Let me create some code to illustrate. (don’t worry about the superfluidity of it)
var tempNum = new Array("");
var numString : String;
function Update(){
if (Input.GetKeyDown(KeyCode.Keypad4)){
tempNum.Add(4.ToString());
numString = parseFloat(tempNum.Join("")).ToString("n2");
}
}
function OnGUI(){
GUI.Label( Rect( 0, 0, 500, 500), numString);
}