# Number

## Overview

Number values represent floating-point numbers.

For more information see: [Number (MDN)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number).

## Properties Summarized

| Type                                                                         | Name                                     | Summary                                                             |
| ---------------------------------------------------------------------------- | ---------------------------------------- | ------------------------------------------------------------------- |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) | [MAX\_VALUE](#max_value)                 | The largest representable number.                                   |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) | [MIN\_VALUE](#min_value)                 | The smallest representable number.                                  |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) | [NEGATIVE\_INFINITY](#negative_infinity) | Special value representing negative infinity; returned on overflow. |
| [Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object) | [NaN](#nan)                              | Special "not a number" value.                                       |
| [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) | [POSITIVE\_INFINITY](#positive_infinity) | Special value representing infinity; returned on overflow.          |

## Methods Summarized

| Type                                                                         | Name                                                           | Summary                                                                                                   |
| ---------------------------------------------------------------------------- | -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) | [toExponential()](#toexponential)                              | Returns a string representing the number in exponential notation.                                         |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) | [toExponential(fractionDigits)](#toexponential-fractiondigits) | Returns a string representing the number in exponential notation.                                         |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) | [toFixed()](#tofixed)                                          | Returns a string representing the number in fixed-point notation.                                         |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) | [toFixed(digits)](#tofixed-digits)                             | Returns a string representing the number in fixed-point notation.                                         |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) | [toLocaleString()](#tolocalestring)                            | Converts the number into a string which is suitable for presentation in the given locale.                 |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) | [toPrecision()](#toprecision)                                  | Returns a string representing the number to a specified precision in fixed-point or exponential notation. |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) | [toPrecision(precision)](#toprecision-precision)               | Returns a string representing the number to a specified precision in fixed-point or exponential notation. |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) | [toString()](#tostring)                                        | Returns a string representing the specified Number object.                                                |
| [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) | [toString(radix)](#tostring-radix)                             | Returns a string representing the specified Number object.                                                |

## Properties Detailed

### MAX\_VALUE

The largest representable number.

**Type**\
[Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
application.output("Largest number: " + Number.MAX_VALUE);
```

### MIN\_VALUE

The smallest representable number.

**Type**\
[Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
application.output("Smallest number: " + Number.MIN_VALUE);
```

### NEGATIVE\_INFINITY

Special value representing negative infinity; returned on overflow.

**Type**\
[Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
application.output("Negative infinity: " + Number.NEGATIVE_INFINITY);
```

### NaN

Special "not a number" value.

**Type**\
[Object](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)

**Sample**

```js
application.output("NaN: " + Number.NaN);
```

### POSITIVE\_INFINITY

Special value representing infinity; returned on overflow.

**Type**\
[Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

**Sample**

```js
application.output("Positive infinity: " + Number.POSITIVE_INFINITY);
```

## Methods Detailed

### toExponential()

Returns a string representing the number in exponential notation.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) A string representing the number in exponential notation.

**Sample**

```js
var n = 123.45678;
application.output(n.toExponential(3));
```

### toExponential(fractionDigits)

Returns a string representing the number in exponential notation.

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **fractionDigits** An integer specifying the number of digits after the decimal point. Defaults to as many digits as necessary to specify the number.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) A string representing the number in exponential notation.

**Sample**

```js
var n = 123.45678;
application.output(n.toExponential(3));
```

### toFixed()

Returns a string representing the number in fixed-point notation.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) A string representing the number in fixed-point notation.

**Sample**

```js
var n = 123.45678;
application.output(n.toFixed(3));
```

### toFixed(digits)

Returns a string representing the number in fixed-point notation.

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **digits** The number of digits to appear after the decimal point. Defaults to 0.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) A string representing the number in fixed-point notation.

**Sample**

```js
var n = 123.45678;
application.output(n.toFixed(3));
```

### toLocaleString()

Converts the number into a string which is suitable for presentation in the given locale.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) A string representing the number in the current locale.

**Sample**

```js
var n = 1000000;
application.output(n.toLocaleString());
```

### toPrecision()

Returns a string representing the number to a specified precision in fixed-point or exponential notation.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) A string representing the number to a specified precision in fixed-point or exponential notation.

**Sample**

```js
var n = 123.45678;
application.output(n.toPrecision(5));
```

### toPrecision(precision)

Returns a string representing the number to a specified precision in fixed-point or exponential notation.

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **precision** An integer specifying the number of significant digits.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) A string representing the number to a specified precision in fixed-point or exponential notation.

**Sample**

```js
var n = 123.45678;
application.output(n.toPrecision(5));
```

### toString()

Returns a string representing the specified Number object.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) A string representing the specified Number object.

**Sample**

```js
var n = 7;
application.output(n.toString()); //displays "7"
application.output(n.toString(2)); //displays "111"
```

### toString(radix)

Returns a string representing the specified Number object.

**Parameters**

* [Number](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number) **radix** An integer between 2 and 36 specifying the base to use for representing numeric values

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) A string representing the specified Number object.

**Sample**

```js
var n = 7;
application.output(n.toString()); //displays "7"
application.output(n.toString(2)); //displays "111"
```

***
