FormatNumber
Last updated
Last updated
// Fixed-point notation
const price = this.api.FormatNumber(123.456789, 2) // Returns "123.46"
const precise = this.api.FormatNumber(123.456789, 4) // Returns "123.4568"
// Scientific notation for small numbers
const small = this.api.FormatNumber(0.000001234, 3) // Returns "1.234e-6"
const tiny = this.api.FormatNumber(0.0000000001, 2) // Returns "1.00e-10"
// Forced scientific notation (negative digits)
const scientific = this.api.FormatNumber(123.456789, -2) // Returns "1.23e+2"
const bigSci = this.api.FormatNumber(123456.789, -3) // Returns "1.235e+5"