1BSON_DECIMAL128_T(3)                libbson               BSON_DECIMAL128_T(3)
2
3
4

NAME

6       bson_decimal128_t - bson_decimal128_t
7
8       BSON Decimal128 Abstraction
9

SYNOPSIS

11          #include <bson/bson.h>
12
13          #define BSON_DECIMAL128_STRING 43
14          #define BSON_DECIMAL128_INF "Infinity"
15          #define BSON_DECIMAL128_NAN "NaN"
16
17          typedef struct {
18          #if BSON_BYTE_ORDER == BSON_LITTLE_ENDIAN
19             uint64_t low;
20             uint64_t high;
21          #elif BSON_BYTE_ORDER == BSON_BIG_ENDIAN
22             uint64_t high;
23             uint64_t low;
24          #endif
25          } bson_decimal128_t;
26

DESCRIPTION

28       The bson_decimal128_t structure represents the IEEE-754 Decimal128 data
29       type. The type bson_decimal128_t is  an  aggregate  that  contains  two
30       uint64_ts, named high and low. The declaration and layout order between
31       them depends on the endian order of the target platform: low  will  al‐
32       ways  correspond  to the low-order bits of the Decimal128 object, while
33       high corresponds to the high-order bits. The  bson_decimal128_t  always
34       has a size of sixteen (16), and can be bit-cast to/from a _Decimal128.
35

EXAMPLE

37          #include <bson/bson.h>
38          #include <stdio.h>
39
40          int
41          main (int argc, char *argv[])
42          {
43             char string[BSON_DECIMAL128_STRING];
44             bson_decimal128_t decimal128;
45
46             bson_decimal128_from_string ("100.00", &decimal128);
47             bson_decimal128_to_string (&decimal128, string);
48             printf ("Decimal128 value: %s\n", string);
49
50             return 0;
51          }
52

AUTHOR

54       MongoDB, Inc
55
57       2017-present, MongoDB, Inc
58
59
60
61
621.24.3                           Aug 17, 2023             BSON_DECIMAL128_T(3)
Impressum