View Full Version : Decimal Place

09 September 2009, 03:05 PM
Is there a way to chop a string value in Maxscript or a Float value to one decimal place.

E.g a float number 1.2345 to a value of 1.2 ?

I've done it so far by collecting the first three characters from a string and creating a new string from that but couldn't find a build in function or way of chopping a string.

Thanks in advance...

09 September 2009, 03:35 PM
Couple easy ways:

local num = dotNetObject "System.Double" 1.2345
local decimals = 1
local result = ((dotNetClass "System.Math").round num decimals) as float
print result

local numstring = "1.2345"
local strNum = (substring numstring 1 3)
print strNum

That dotNet method does rounding also.

09 September 2009, 03:40 PM
Hi hotknife,
take a look at FormattedPrint in MaxScript Reference. It provides a lot of options.

- Enrico

09 September 2009, 07:09 PM

09 September 2009, 08:52 PM
Thanks guys all good.

CGTalk Moderation
09 September 2009, 08:52 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.