round

The round filter rounds a number to a given precision:

ラウンド フィルターは、数値を指定された精度に丸めます。
1
2
3
4
5
{{ 42.55|round }}
{# outputs 43 #}

{{ 42.55|round(1, 'floor') }}
{# outputs 42.5 #}

The round filter takes two optional arguments; the first one specifies the precision (default is 0) and the second the rounding method (default is common):

ラウンド フィルターは、2 つのオプションの引数を取ります。最初のものは精度 (デフォルトは 0) を指定し、2 つ目は丸め方法 (デフォルトは共通) を指定します。
  • common rounds either up or down (rounds the value up to precision decimal places away from zero, when it is half way there -- making 1.5 into 2 and -1.5 into -2);
    common は、切り上げまたは切り下げを行います (値がゼロから離れた精度の小数位まで切り上げます。値が半分になると、1.5 は 2 になり、-1.5 は -2 になります)。
  • ceil always rounds up;
    ceil は常に切り上げます。
  • floor always rounds down.
    floor は常に切り捨てます。

Note

ノート

The // operator is equivalent to |round(0, 'floor').

// 演算子は |round(0, 'floor') と同等です。

Arguments

  • precision: The rounding precision
    precision: 丸め精度
  • method: The rounding method
    method: 丸め方法