1BSON::Double(3) User Contributed Perl Documentation BSON::Double(3)
2
3
4
6 BSON::Double - BSON type wrapper for Double
7
9 version v1.12.2
10
12 use BSON::Types ':all';
13
14 my $bytes = bson_double( $number );
15
17 This module provides a BSON type wrapper for a numeric value that would
18 be represented in BSON as a double.
19
21 value
22 A numeric scalar (or the special strings "Inf", "-Inf" or "NaN"). This
23 will be coerced to Perl's numeric type. The default is 0.0.
24
26 TO_JSON
27 Returns a double.
28
29 If the "BSON_EXTJSON" environment variable is true and the
30 "BSON_EXTJSON_RELAXED" environment variable is false, returns a hashref
31 compatible with MongoDB's extended JSON
32 <https://github.com/mongodb/specifications/blob/master/source/extended-
33 json.rst> format, which represents it as a document as follows:
34
35 {"$numberDouble" : "42.0"}
36
37 If "BSON_EXTJSON" is false and the value is 'Inf', '-Inf' or 'NaN'
38 (which are illegal in regular JSON), then an exception is thrown.
39
41 Some Perls may not support converting "Inf" or "NaN" strings to their
42 double equivalent. They are available as functions from the POSIX
43 module, but as a lighter alternative to POSIX, the following functions
44 are available:
45
46 • BSON::Double::pInf() – positive infinity
47
48 • BSON::Double::nInf() – negative infinity
49
50 • BSON::Double::NaN() – not-a-number
51
53 The numification operator, "0+" is overloaded to return the "value",
54 the full "minimal set" of overloaded operations is provided (per
55 overload documentation) and fallback overloading is enabled.
56
58 • David Golden <david@mongodb.com>
59
60 • Stefan G. <minimalist@lavabit.com>
61
63 This software is Copyright (c) 2020 by Stefan G. and MongoDB, Inc.
64
65 This is free software, licensed under:
66
67 The Apache License, Version 2.0, January 2004
68
69
70
71perl v5.36.0 2022-07-22 BSON::Double(3)