Truncate decimals for fps when a whole number

All about user-defined episode / movie / file name format expressions
Post Reply
jerome
Posts: 31
Joined: 25 Feb 2019, 02:21

Truncate decimals for fps when a whole number

Post by jerome »

I know that fps is "decimal" like ratings and in the forums I found some postings on rounding to various decimal places but nothing on how to truncate the decimal places when it is a whole number.

For example, I'm okay with 23.976, but if the fps is a whole number like 25.000 I would prefer that it show as just 25.

Thanks
J
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Truncate decimals for fps when a whole number

Post by rednoah »

Try BigDecimal.stripTrailingZeros() like so:

Code: Select all

{fps.stripTrailingZeros()}
:idea: Please read the FAQ and How to Request Help.
jerome
Posts: 31
Joined: 25 Feb 2019, 02:21

Re: Truncate decimals for fps when a whole number

Post by jerome »

{fps.stripTrailingZeros()} does not work perfectly because 20 becomes 2E+1, 30 becomes 3E+1 and so forth. Does not work well for multiples of 10.

Had to do some Java research and adding .toPlainString() will fix this so that 20 stays as 20 and so forth, in case anyone else is interested.
{fps.stripTrailingZeros().toPlainString()'}
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Truncate decimals for fps when a whole number

Post by rednoah »

I see. That's problematic. I'll make sure not to use stripTrailingZeros() implicitly for built-in bindings then.
:idea: Please read the FAQ and How to Request Help.
Post Reply