PDA

View Full Version : limiting the number of decimals


dunkel3d
07-05-2003, 03:43 AM
my expression prints out the translation values of my objec:

1.4871941.487194 4 -1.2380914.443491265

is there a way to limit the number of decimal points to something like:

1.487 4 -1.238

?
S

sedric
07-05-2003, 07:24 AM
you might want to try the trunc command...if you look in the help files, it says that it will return the largest whole value that is not greater than the argument.

so trunc (3.6879586) will return 3

you can control number of decimals places in your float using this command by first multiplying your float by a large number , trunicating it , then deviding it by the same number.

float $foo = (trunc (3.6879586 * 1000) / 1000)

$foo will equal 3.687

you can use 100 or 10000000 or whatever you want....depending on the precision you want

dunkel3d
07-05-2003, 09:34 PM
thanks sedric

CGTalk Moderation
01-15-2006, 01:00 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.