# man > BSON::Double(3pm)

---
type: CommandReference
command: BSON::Double
mode: perldoc
section: 3pm
source: perldoc
---
## Quick Reference
- `bson_double(42.0)` — wrap a number as a BSON double
- `BSON::Double->new(value => "Inf")` — create positive infinity double
- `BSON::Double::pInf()` — positive infinity value
- `BSON::Double::nInf()` — negative infinity value
- `BSON::Double::NaN()` — not‑a‑number value
- `$double->TO_JSON()` — serialize to JSON (extended JSON if env set)

## Name
BSON::Double — BSON type wrapper for Double

## Synopsis
perl
use BSON::Types ':all';
my $bytes = bson_double( $number );
## Attributes
- `value` — numeric scalar (or `"Inf"`, `"-Inf"`, `"NaN"`), coerced to Perl’s numeric type. Default: `0.0`.

## Methods
- `TO_JSON()` — returns a double. If `BSON_EXTJSON` env is true and `BSON_EXTJSON_RELAXED` env is false, returns a hashref compatible with MongoDB extended JSON (e.g., `{"$numberDouble": "42.0"}`). If `BSON_EXTJSON` is false and the value is `Inf`, `-Inf`, or `NaN`, throws an exception.

## Infinity and NaN
Special double values, as a lighter alternative to POSIX:
- `BSON::Double::pInf()` – positive infinity
- `BSON::Double::nInf()` – negative infinity
- `BSON::Double::NaN()` – not‑a‑number

## Overloading
- Numification (`0+`) returns the `value`.
- Full “minimal set” of overloaded operations provided with fallback enabled.

## See Also
- [BSON::Types](http://localhost/phpMan.php/perldoc/BSON%3A%3ATypes/markdown)
- [MongoDB Extended JSON specification](https://github.com/mongodb/specifications/blob/master/source/extended-json.rst)