BSON::Decimal128(3pm)

πŸ“¦
version 1.12.2 Β· 5 versions
, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ’– 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 16 bytes, 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. 😌


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