سؤال

I have a number, 2.0e-14, and I want to convert it to string. I'm using (2.0e-14).toString(), and what I get is the string 2e-14, because it's removing the zeroes at the right.

Is there any way of keep the zero at the right than to manipulating the string?

هل كانت مفيدة؟

المحلول

Use the Number toPrecision method.

(2.0e-14).toPrecision(2)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top