Reducing the number of decimals in a floating point value

Post Reply
User avatar
Loki
Posts: 12
Joined: 19 Jun 2009, 17:07

Reducing the number of decimals in a floating point value

Post by Loki » 15 Jul 2010, 10:26

Hi

I'm tryng to animate a text that display the distance between two objects.
I reach to add a scripted operator and to connect it to a ctr_dist value.

The problem is that the value I obtain with GetValue is a floating point with 16 decimals.
Here te result:
Image

How I can reduce the number of decimals? I need to display only one or two decimals.
I tried also to convert the value from Float to Integer and creating two animated text, but as you can see in the pictures, the values are (obviously) approximated to the near integer and so, a value of 8,61 is displayed as 9.

Anyone knows how to solve it?
(sorry for my english)

craft
Posts: 107
Joined: 03 Jan 2010, 00:40
Location: Portugal
Contact:

Re: Reducing the number of decimals in a floating point value

Post by craft » 15 Jul 2010, 17:25

round(ctr_dist( _nl., _nl1. ) * 100) / 100 - put this in the "Value" parameter
maybe there's even an easier way, but this is what came to my mind right away.

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests