---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---
# Number.prototype.toFixed()

The **`toFixed()`** method formats a number using fixed-point notation.

## Syntax

```js
toFixed()
toFixed(digits)
```

### Parameters

- `digits` _**optional**_
  - : The number of digits to appear after the decimal point; should be a value between `0` and `100`, inclusive. If this argument is omitted, it is treated as `0`.

### Return value

A string representing the given number using fixed-point notation.

### Exceptions

- [`RangeError`](../../../globals/RangeError/RangeError.mdx)
  - : If `digits` is smaller than `0`, larger than `100`, or is `NaN`.
- [`TypeError`](../../../globals/TypeError/TypeError.mdx)
  - : If this method is invoked on an object that is not a `Number`.

## Description

The `toFixed()` method returns a string representation of `numObj` that does not use exponential notation and has exactly `digits` digits after the decimal place. The number is rounded if necessary, and the fractional part is padded with zeros if necessary so that it has the specified length.

If the absolute value of `numObj` is greater or equal to 10<sup>21</sup>, this method uses the same algorithm as [`Number.prototype.toString()`](../../../globals/Number/prototype/toString.mdx) and returns a string in exponential notation. `toFixed()` returns `"Infinity"`, `"NaN"`, or `"-Infinity"` if the value of `numObj` is non-finite.

The output of `toFixed()` may be more precise than [`toString()`](../../../globals/Number/prototype/toString.mdx) for some values, because `toString()` only prints enough significant digits to distinguish the number from adjacent number values. For example:

```js
(1000000000000000128).toString(); // '1000000000000000100'
(1000000000000000128).toFixed(0); // '1000000000000000128'
```

However, choosing a `digits` precision that's too high can return unexpected results, because decimal fractional numbers cannot be represented precisely in floating point. For example:

```js
0.3.toFixed(50); // '0.29999999999999998889776975374843459576368331909180'
```
