PDA

View Full Version : Decimal Place


hotknife
09-11-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...

VVaari
09-11-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.

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

- Enrico

Polimeno
09-11-2009, 07:09 PM
http://forums.cgsociety.org/showthread.php?f=98&t=800817

hotknife
09-15-2009, 08:52 PM
Thanks guys all good.

CGTalk Moderation
09-15-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.