Jump to content
EdwardBrian

Need two decimals

Recommended Posts

Hi,

one of those questions where the answer is propably easier than binding your shoes but you didn´t have a coffee for several hours and therefor your brain is frozen (thats me...)

My Problem: Im am using a font sop to display the distance an object is traveling in the scene (simulating a digital display). I just don´t get it right so that it is 1.) only displaying 2 decimal points like 25.76 and 2.) displays 34.00 and not 34 as it is automatically doing.

Any help will be highly appreciated.

Share this post


Link to post
Share on other sites

for 1) you can use trunc like so:

trunc(100*$ATTRIBUTE)/100

but you are right, when there is an end-zero it will not display it, so I don't know the answer to 2) unless you want to use Python, in which case it is probably is quite easy.

Share this post


Link to post
Share on other sites

As an hscript expression in the 'Text' field of a FontSOP?

Maybe you can try:

`padzero(2,trunc($NUM))`.`padzero(2,trunc(round(frac($NUM)*100)))`

Where you'd replace '$NUM' with whatever the number is that you need to represent, and change the two constants ('2') with the amount of zero-padding you want on either side of the decimal point (which the power-of-ten on the right side should also match, of course).

Cheers.

Share this post


Link to post
Share on other sites

I've been trying this function, but with the attempt of only showing 1 decimal. However I do it, it seems to sometimes show .10 instead of .0.

How do I get around that?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×