0

How do you add additional zero(s) at the end of a number?

For example, if the user choose "0" in the Precision column the Lower Limit value will show like this: Precision: 0, Lower Limit: 90%

If "1":

Precision: 1, Lower Limit: 90.0%

If "2":

Precision: 2, Lower Limit: 90.00%

Elijah Mock
  • 587
  • 8
  • 21
  • the best way to do this (assuming you want something other than zeros at the end sometimes) is to store the value with full precision (ie 90.1234), then use you can use something like https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_objects/Number/toPrecision to filter it before you send it to the UI. – Dr_Derp Nov 27 '19 at 01:31
  • Thanks sir, but my problem is to add zero at the end of number and it will depends in the number of precision –  Nov 27 '19 at 01:36
  • See https://stackoverflow.com/questions/6134039/format-number-to-always-show-2-decimal-places#answer-6134070 – Elijah Mock Nov 27 '19 at 02:32

1 Answers1

1

You can specify the number of decimals to be rendered by using the .toFixed() method.

Number.pototype.toFixed()

soma
  • 91
  • 1
  • 1
  • 12