# man > BSON::Int64

---
type: CommandReference
command: BSON::Int64
mode: perldoc
section: 3pm
source: perldoc
---

## Quick Reference
- `use BSON::Types ':all';` — import `bson_int64`
- `bson_int64($number)` — wrap a number as a BSON 64‑bit integer
- `BSON::Int64->new(value => $number)` — constructor alternative
- `$obj->value` — get the numeric scalar (defaults to 0)
- `0+$obj` — numification overload returns the value
- `$obj->TO_JSON` — serialise for JSON (respects `BSON_EXTJSON`/`BSON_EXTJSON_RELAXED`)

## Name
BSON::Int64 — BSON type wrapper for 64‑bit integers

## Synopsis
perl
use BSON::Types ':all';
bson_int64( $number );
## Attributes and Methods
- `value` — numeric scalar, coerced to an integer; default 0.
- `TO_JSON` — on 64‑bit Perl returns the value as an integer; on 32‑bit Perl returns a `Math::BigInt` object.  
  If `$ENV{BSON_EXTJSON}` is true and `$ENV{BSON_EXTJSON_RELAXED}` is false, returns a hashref: `{ '$numberLong' => '223372036854775807' }`.
- Overloading: the `0+` (numification) operator returns `value`; full minimal overload set provided, with fallback enabled.

## Examples
perl
use BSON::Types ':all';
my $int = bson_int64(42);
print 0 + $int;   # 42
perl
local $ENV{BSON_EXTJSON} = 1;
local $ENV{BSON_EXTJSON_RELAXED} = 0;
my $int = bson_int64(223372036854775807);
my $json = $int->TO_JSON;  # { '$numberLong' => '223372036854775807' }
## See Also
- [BSON](http://localhost/phpMan.php/perldoc/BSON/markdown)
- [BSON::Types](http://localhost/phpMan.php/perldoc/BSON%3A%3ATypes/markdown)
- [Math::BigInt](http://localhost/phpMan.php/perldoc/Math%3A%3ABigInt/markdown)