* Round the `value` when the rounding method deals with '.05' * * @param {string} value * @param {object} settings * @returns {string} * @private
(value, settings)
| 5915 | * @private |
| 5916 | */ |
| 5917 | static _roundCloseTo05(value, settings) { |
| 5918 | switch (settings.roundingMethod) { |
| 5919 | case AutoNumeric.options.roundingMethod.toNearest05: |
| 5920 | case AutoNumeric.options.roundingMethod.toNearest05Alt: |
| 5921 | value = (Math.round(value * 20) / 20).toString(); |
| 5922 | break; |
| 5923 | case AutoNumeric.options.roundingMethod.upToNext05: |
| 5924 | value = (Math.ceil(value * 20) / 20).toString(); |
| 5925 | break; |
| 5926 | default : |
| 5927 | value = (Math.floor(value * 20) / 20).toString(); |
| 5928 | } |
| 5929 | |
| 5930 | let result; |
| 5931 | if (!AutoNumericHelper.contains(value, '.')) { |
| 5932 | result = value + '.00'; |
| 5933 | } else if (value.length - value.indexOf('.') < 3) { |
| 5934 | result = value + '0'; |
| 5935 | } else { |
| 5936 | result = value; |
| 5937 | } |
| 5938 | |
| 5939 | return result; |
| 5940 | } |
| 5941 | |
| 5942 | /** |
| 5943 | * Modify the given `value` in order to make it usable for the rest of the rounding function. |