[SNIPPET] Rounding numbers (for ratings)

All about user-defined episode / movie / file name format expressions
Post Reply
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

[SNIPPET] Rounding numbers (for ratings)

Post by rednoah »

Here's some code that'll show you how to round numbers in Groovy.


e.g. round to nearest Integer and format as Integer, i.e. 7, 8, 9, ...

Format: Select all

{ rating.round() }

e.g. round to nearest Integer and format as Decimal, i.e. 7.0, 8.0, 9.0, ...

Format: Select all

{ rating.round(0) }

e.g. round to the nearest 1/10 fraction, i.e. 7.1, 8.2, 9.3, ...

Format: Select all

{ rating.round(1) }
:idea: Please read the FAQ and How to Request Help.
Post Reply