man > BSON::Decimal128

πŸ“› NAME

BSON::Decimal128 - BSON type wrapper for Decimal128

πŸš€ Quick Reference

Use CaseCommandDescription
πŸ”’ Create from stringbson_decimal128("123.45")Create a Decimal128 object from a numeric string
πŸ“¦ Create from BID bytesBSON::Decimal128->new(bytes => $bid)Create from a 16‑byte BID binary representation
πŸ“€ Get string value$d->valueReturns the decimal as a normalised string
πŸ’Ύ Get BID bytes$d->bytesReturns the underlying 16‑byte binary data
πŸ”§ JSON serialisation$d->TO_JSONReturns string or extended JSON with $numberDecimal

πŸ”– VERSION

version v1.12.2

πŸ“‹ SYNOPSIS

use BSON::Types ':all';

# string representation
$decimal = bson_decimal128( "1.23456789E+1000" );

# binary representation in BID format
$decimal = BSON::Decimal128->new( bytes => $bid )

ℹ️ DESCRIPTION

πŸ“¦ This module provides a BSON type wrapper for Decimal128 values.

πŸ”’ It may be initialised with either a numeric value in string form, or with a binary Decimal128 representation (16 bytes), but not both.

⚠️ Initialisation from a string will throw an error if the string cannot be parsed as a Decimal128 or if the resulting number would not fit into 128 bits. If required, clamping or exact rounding will be applied to try to fit the value into 128 bits.

🏷️ ATTRIBUTES

πŸ”Ή value

πŸ“ The Decimal128 value represented as string. If not provided, it will be generated from the bytes attribute on demand.

πŸ”Ή bytes

πŸ“ The Decimal128 value represented in Binary Integer Decimal (BID) format. If not provided, it will be generated from the value attribute on demand.

βš™οΈ METHODS

πŸ”§ TO_JSON

πŸ“€ Returns the value as a string.

πŸ”§ If the BSON_EXTJSON option is true, it will instead be compatible with MongoDB’s extended JSON (extended JSON) format, which represents it as a document as follows:

{"$numberDecimal" : "2.23372036854775807E+57"}

πŸ”„ OVERLOADING

⚑ The stringification operator ("") is overloaded to return a (normalised) string representation. Fallback overloading is enabled.

πŸ‘₯ AUTHORS

©️ COPYRIGHT AND LICENSE

πŸ“œ This software is Copyright (c) 2020 by Stefan G. and MongoDB, Inc.

πŸ“œ This is free software, licensed under:

The Apache License, Version 2.0, January 2004
BSON::Decimal128
πŸ“› NAME πŸš€ Quick Reference πŸ”– VERSION πŸ“‹ SYNOPSIS ℹ️ DESCRIPTION 🏷️ ATTRIBUTES
πŸ”Ή value πŸ”Ή bytes
βš™οΈ METHODS
πŸ”§ TO_JSON
πŸ”„ OVERLOADING πŸ‘₯ AUTHORS ©️ COPYRIGHT AND LICENSE

Generated by phpman v4.9.25-4-g0d844aa · Markdown · JSON · MCP Author: Che Dong Under GNU General Public License
2026-07-07 09:11 @216.73.217.93
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
Valid XHTML 1.0 Transitional!Valid CSS!
Enhanced by LLM: deepseek-v4-pro / taotoken.net / www.chedong.com - original format