Format Percentage

Format a decimal number as a percentage with configurable precision.

Code

Utilities
"#{(num * 100).round(decimals)}%"

Parameters

The decimal number (0-1).

Decimal places to show.

Server

More Ruby Snippets