toPrecision Summary Formats the double value as a string to the given precision. Usage public string toPrecision(int precision) Returns The double value formatted using to the given precision. Parameters precision The number of significant digits in the final formatted value. This number can be between 1 and 21 (inclusive). Description Formats the double value to the given precision. The formatted value will be returned as a string. System.Exceptions.OutOfRangeException will be thrown if the supplied argument for the significant digits is not an integer between 1 and 21 (inclusive). Examples Basic Usage 1234567import System; System.Double x = new System.Double(1d);Console.log(x.toPrecision(1)); // "1"Console.log(x.toPrecision(2)); // "1.0"Console.log(x.toPrecision(5)); // "1.0000"Console.log(x.toPrecision(7)); // "1.000000" Share HTML | BBCode | Direct Link