PDA

View Full Version : How to I omit the decimal in string?


wongwanchap
03-03-2009, 10:41 AM
I use the code below:

Number a=1;
Text.String=toString(Math.floor(a));


Here "Text" is the object name of 3D text.

And the output is 1.0

I have already floor it, why the decimal still there?
How can I omit decimal, to get the output as 1 not 1.0?

zonedabone
03-05-2009, 09:56 PM
There is only one possible way to do this in alice, and it';s not straight forward. Drag the text property of the 3d text into an event. When it asks what to change the text to, put the "to string" function in. Into that, drag the random number function. Set the minimum and maximum parameters on the random number generator to your number. Set "Integer only" to true. This will set the 3d text as that number without a decimal. http://sites.google.com/a/scasd.org/pauleypress-com/Home/untitled.bmp?attredirects=0

wongwanchap
03-06-2009, 03:23 AM
It works, thanks.

Btw, how can u discover this solution, it seems no clue to solve it.