I am developing a site with javascript, which does the following, the visitor will enter the unit quantity, the unit to compare and the unit of comparison (Ex: 12 centimeters for millimeter) and it will show how much the quantity of the unit to compare is equivalent to the unit of comparison, the only problem is that if I put a unit to compare too small and a unit to compare too large, it will happen that the result will be wrong (Ex: 17 decimeters for kilometers will give 0, 0170000000000001) so I asked a person and they replied that I should use scientific notation, but I have no idea how to do it in javascript, could anyone help me?
Do you mean something like this?
number.toExponential(x)
x can go from 0 to 20. It's the number of digits after the decimal point.