|
1 | 1 | rounding_mode |
2 | 2 | ~~~~~~~~~~~~~ |
3 | 3 |
|
4 | | -**type**: ``integer`` **default**: ``NumberToLocalizedStringTransformer::ROUND_HALF_UP`` |
| 4 | +**type**: ``integer`` **default**: ``\NumberFormatter::ROUND_HALFUP`` |
5 | 5 |
|
6 | | -If a submitted number needs to be rounded (based on the `scale`_ |
7 | | -option), you have several configurable options for that rounding. Each |
8 | | -option is a constant on the :class:`Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer`: |
| 6 | +If a submitted number needs to be rounded (based on the `scale`_ option), you |
| 7 | +have several configurable options for that rounding. Each option is a constant |
| 8 | +on the ``\NumberFormatter`` class: |
9 | 9 |
|
10 | | -* ``NumberToLocalizedStringTransformer::ROUND_DOWN`` Round towards zero. It |
| 10 | +* ``\NumberFormatter::ROUND_DOWN`` Round towards zero. It |
11 | 11 | rounds ``1.4`` to ``1`` and ``-1.4`` to ``-1``. |
12 | 12 |
|
13 | | -* ``NumberToLocalizedStringTransformer::ROUND_FLOOR`` Round towards negative |
| 13 | +* ``\NumberFormatter::ROUND_FLOOR`` Round towards negative |
14 | 14 | infinity. It rounds ``1.4`` to ``1`` and ``-1.4`` to ``-2``. |
15 | 15 |
|
16 | | -* ``NumberToLocalizedStringTransformer::ROUND_UP`` Round away from zero. It |
| 16 | +* ``\NumberFormatter::ROUND_UP`` Round away from zero. It |
17 | 17 | rounds ``1.4`` to ``2`` and ``-1.4`` to ``-2``. |
18 | 18 |
|
19 | | -* ``NumberToLocalizedStringTransformer::ROUND_CEILING`` Round towards positive |
| 19 | +* ``\NumberFormatter::ROUND_CEILING`` Round towards positive |
20 | 20 | infinity. It rounds ``1.4`` to ``2`` and ``-1.4`` to ``-1``. |
21 | 21 |
|
22 | | -* ``NumberToLocalizedStringTransformer::ROUND_HALF_DOWN`` Round towards the |
| 22 | +* ``\NumberFormatter::ROUND_HALFDOWN`` Round towards the |
23 | 23 | "nearest neighbor". If both neighbors are equidistant, round down. It rounds |
24 | 24 | ``2.5`` and ``1.6`` to ``2``, ``1.5`` and ``1.4`` to ``1``. |
25 | 25 |
|
26 | | -* ``NumberToLocalizedStringTransformer::ROUND_HALF_EVEN`` Round towards the |
| 26 | +* ``\NumberFormatter::ROUND_HALFEVEN`` Round towards the |
27 | 27 | "nearest neighbor". If both neighbors are equidistant, round towards the even |
28 | 28 | neighbor. It rounds ``2.5``, ``1.6`` and ``1.5`` to ``2`` and ``1.4`` to ``1``. |
29 | 29 |
|
30 | | -* ``NumberToLocalizedStringTransformer::ROUND_HALF_UP`` Round towards the |
| 30 | +* ``\NumberFormatter::ROUND_HALFUP`` Round towards the |
31 | 31 | "nearest neighbor". If both neighbors are equidistant, round up. It rounds |
32 | 32 | ``2.5`` to ``3``, ``1.6`` and ``1.5`` to ``2`` and ``1.4`` to ``1``. |
| 33 | + |
| 34 | +.. deprecated:: 5.1 |
| 35 | + |
| 36 | + In Symfony versions prior to 5.1, these constants were also defined as aliases |
| 37 | + in the :class:`Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer` |
| 38 | + class, but they are now deprecated in favor of the ``\NumberFormatter`` constants. |
0 commit comments