BSON::Decimal128(3pm)
π BSON::Decimal128 π
okay bestie, so this is BSON::Decimal128 β the Perl module that's literally a BSON type wrapper for Decimal128. she's giving big-numbers-in-a-tiny-box energy and honestly? iconic. π
β¨ VERSION β¨
version v1.12.2 β yes, that's the one, write it down π
πΈ SYNOPSIS πΈ
okay so here's the vibe, look:
use BSON::Types ':all';
# string representation
$decimal = bson_decimal128( "1.23456789E+1000" );
# binary representation in BID format
$decimal = BSON::Decimal128->new( bytes => $bid )
see how we pulled in BSON::Types with ':all'? that's how you get bson_decimal128 in your life. and then you can either hand her a string or hand her raw bytes β pick a lane, bestie. π¦
π DESCRIPTION π
This module provides a BSON type wrapper for Decimal128 values. periodt. π
She can be initialized one of two ways, and listen β it's either/or, not both:
- with a numeric value in string form, or
- with a binary Decimal128 representation (that's
16bytes, for the record)
Initialization 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. like, she's trying her best but she has limits. π
And if required? clamping or exact rounding will be applied to try to fit the value into 128 bits. so she'll squish it in there for you. π«Ά
π§ ATTRIBUTES π§
π value
The Decimal128 value represented as string. If not provided, it will be generated from the "bytes" attribute on demand. lowkey lazy but in a cute way, she only does the work when you ask. β¨
π bytes
The Decimal128 value represented in Binary Integer Decimal (BID) format β you know, the [Binary Integer Decimal](https://en.wikipedia.org/wiki/Binary_Integer_Decimal) thing. If not provided, it will be generated from the "value" attribute on demand. she's flexible like that. π
π₯ METHODS π₯
π TO_JSON
Returns the value as a string. simple. clean. no notes. π
BUT β and this is the plot twist β if the "BSON_EXTJSON" option is true, it will instead be compatible with MongoDB's [extended JSON](https://github.com/mongodb/specifications/blob/master/source/extended-json.rst) format, which represents it as a document as follows:
{"$numberDecimal" : "2.23372036854775807E+57"}
that $numberDecimal key? yeah, that's the extended-JSON glow-up. π
π OVERLOADING π
The stringification operator ("") is overloaded to return a (normalized) string representation. Fallback overloading is enabled. so like, if you just print her, she shows up looking pretty and normalized. main character energy fr fr. π
π«Ά AUTHORS π«Ά
- David Golden
<david@mongodb.com> - Stefan G.
<minimalist@lavabit.com>
two legends, we stan. π
π 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
free software?? we love a generous queen. π
okay that's the whole page bestie, and just so you have the receipts: this ships as part of BSON::Decimal128 β that's the manual page for the Perl-verse β and the footer says it was generated by perl v5.30.3 on 2020-08-14. so like, vintage but make it slay. πβ¨π¦πΈπ
ππβπ
π¦ where this page comes from
- debian bookworm: libbson-perl 1.12.2-1 Β· Apache-2.0
- ubuntu jammy: libbson-perl 1.12.2-1 Β· Apache-2.0
- ubuntu noble: libbson-perl 1.12.2-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms