@@ -141,10 +141,11 @@ the following operation in the :program:`mongo` shell:
141
141
NumberLong
142
142
----------
143
143
144
- The :program:`mongo` shell provides the ``NumberLong()`` class to handle
145
- numbers of type long.
144
+ By default, the :program:`mongo` shell treats all numbers as
145
+ floating-point values. The :program:`mongo` shell provides the
146
+ ``NumberLong()`` class to handle numbers of 64-bit integers.
146
147
147
- The ``NumberLong()`` accepts the long as a string:
148
+ The ``NumberLong()`` constructor accepts the long as a string:
148
149
149
150
.. code-block:: javascript
150
151
@@ -159,21 +160,26 @@ collection:
159
160
db.collection.update( { _id: 10 },
160
161
{ $set: { calc: NumberLong("209084588685266550") } } )
161
162
162
- .. wiki content -- I don't think the following applies anymore
163
-
164
- Numbers
165
- By default, the shell treats all numbers as floating-point values.
166
- You have the option to work with 64-bit integers by using a class
167
- built into the shell called NumberLong() If you have long/integer
168
- BSON data from the database you may see something like this:
169
- {"count" : NumberLong("575175")}
170
- Setting/incrementing any number from javascript will (most likely)
171
- change the data type to a floating point value.
172
- Here is an example of creating a document with a long field:
173
- doc = { field: new NumberLong("123212313")}
174
- Note that prior to 1.6 long numbers might be displayed like this:
175
- "bytes" : {
176
- "floatApprox" : 5284376243087482000,
177
- "top" : 1230364721,
178
- "bottom" : 4240317554
179
- }
163
+ If you :operator:`increment <$inc>` the field that contains a
164
+ ``NumberLong`` object, the data type changes to a floating point value,
165
+ as in the following example:
166
+
167
+ #. :operator:`Increment <$inc>` the ``calc`` field:
168
+
169
+ .. code-block:: javascript
170
+
171
+ db.collection.update( { _id: 10 },
172
+ { $inc: { calc: 5 } } )
173
+
174
+ #. Select the updated document:
175
+
176
+ .. code-block:: javascript
177
+
178
+ db.collection.findOne( { _id: 10 } )
179
+
180
+ In the updated document, the ``calc`` field contains a floating
181
+ point value:
182
+
183
+ .. code-block:: sh
184
+
185
+ { "_id" : 10, "calc" : 209084588685266560 }
0 commit comments