Jump to content

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.

Link to comment
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.

Link to comment
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.

  • Like 2
Link to comment
Share on other sites

  • 7 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...