# FormatNumber

Formats a number with specified precision.

## Syntax

```typescript
FormatNumber(value: number, digits = 8): string
```

## Parameters

* `value`: `number` - The number to format
* `digits`: `number` - The number of decimal places or exponent digits (-16 to 16)

## Return Value

Returns a `string` representing the formatted number.

## Description

The `FormatNumber` method formats a number with specified precision. It handles both regular decimal notation and scientific notation based on the value and digits parameter:

* For digits >= 0 and <= 16:
  * Uses fixed-point notation for normal numbers
  * Uses scientific notation for very small numbers (abs < 1e-6)
* For digits >= -16 and <= -1:
  * Uses scientific notation with abs(digits) decimal places
* For digits outside these ranges:
  * Defaults to 8 decimal places

## Example

```typescript
// 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"
```
