BSON_APPEND_DECIMAL128(3)
π BSON_APPEND_DECIMAL128 β bestie's guide to the libbson decimal128 append
okay so real talk, this is a page from libbson (the BSON_APPEND_DECIMAL128(3) one, yes that's the whole title, we're doing this) and honestly? it's a little baby page. one function, one macro, four params, zero drama. let's get into it β¨
β¨ SYNOPSIS β¨
here's the whole vibe, copy it exactly bestie:
#define BSON_APPEND_DECIMAL128(b, key, val) \
bson_append_decimal128 (b, key, (int) strlen (key), val)
bool
bson_append_decimal128 (bson_t *bson,
const char *key,
int key_length,
const bson_decimal128_t *value);
so you got a macro up top that's just a lil shortcut β it calls the real function and does the strlen (key) thing for you so you don't have to π«Ά and then the actual function signature underneath, returning a bool like the good little truth-teller it is.
πΈ PARAMETERS πΈ
bsonβ abson_t. it's the document, it's the moment, it's the main character. you're appending into this one πkeyβ an ASCII C string with the name of the field. yes, ASCII. keep it simple, keep it iconic.key_lengthβ the length ofkeyin bytes. ORRR you can be lazy (affectionate) and pass-1to let it figure the length out withstrlen()β¨valueβ abson_decimal128_t. that's the thing you're shoving in there.
π¦ DESCRIPTION π¦
so the bson_append_decimal128() function shall append a new element to bson containing a Decimal 128. that's it. that's the whole job. it does one thing and it slays at it π
no cap, no hidden features, no secret lore.
π RETURNS π
returns true if the operation was applied successfully β we love a success story π₯³
β οΈ but heads up bestie: the function will fail if appendingvaluegrowsbsonlarger thanINT32_MAX. so if your doc is already living its best absolute unit life, this is where it taps out. not a vibe, just facts π
π AUTHOR π
MongoDB, Inc β the ones who brought you this whole situation π«Ά
π COPYRIGHT π
2009-present, MongoDB, Inc. β periodt, that's the legal bit, we respect it.
π§ and that's the tea! go forth and append your decimals, you absolute icon β
libbson version 2.5.6, dated Oct 09, 2026 β that's when this gem got its timestamp, and honestly? she's timeless π bye bestie!! π
π¦ where this page comes from
- epel 10: libbson-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms