Hi,
I'm writing a script that exports the position of an object. In the process, I'm truncating them to only four decimals.
Wrote the a truncate function. It works but not on low numbers.
For example,
Actual Position: Vector(0, 139.213, 93.26)
X-Position: 2.42398958609e-05
Resulting truncation: 2.4239
It turns out the script reads the pseudo decimal
to an actual decimal. Is there a way to read the numbers as this 0.0000242398958609
so the function works as expected or should I revise the function?
Here is the current code:
def truncate(num):
num_str = str(num)
num = num_str.split(".")
num_real = num[0]
num_dec = num[1][:4]
new_num_str = "{}.{}".format(num_real, num_dec)
new_num = float(new_num_str)
return new_num