1BSON_DECIMAL128_T(3)                libbson               BSON_DECIMAL128_T(3)
2
3
4
5BSON Decimal128 Abstraction
6

SYNOPSIS

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

DESCRIPTION

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

EXAMPLE

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

AUTHOR

51       MongoDB, Inc
52
54       2017-present, MongoDB, Inc
55
56
57
58
591.25.1                           Nov 08, 2023             BSON_DECIMAL128_T(3)
Impressum