Notifications
Clear all

[Closed] Decimal Place

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…

4 Replies

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.

Hi hotknife,
take a look at FormattedPrint in MaxScript Reference. It provides a lot of options.

  • Enrico

Thanks guys all good.