@@ -143,35 +143,51 @@ NumberLong
143143
144144By default, the :program:`mongo` shell treats all numbers as
145145floating-point values. The :program:`mongo` shell provides the
146- ``NumberLong()`` class to handle numbers of 64-bit integers.
146+ ``NumberLong()`` class to handle 64-bit integers.
147147
148148The ``NumberLong()`` constructor accepts the long as a string:
149149
150150.. code-block:: javascript
151151
152- NumberLong("20908458868526654 ")
152+ NumberLong("2090845886852 ")
153153
154154The following examples use the ``NumberLong()`` class to write to the
155155collection:
156156
157157.. code-block:: javascript
158158
159- db.collection.insert( { _id: 10, calc: NumberLong("20908458868526654 ") } )
159+ db.collection.insert( { _id: 10, calc: NumberLong("2090845886852 ") } )
160160 db.collection.update( { _id: 10 },
161- { $set: { calc: NumberLong("209084588685266550") } } )
161+ { $set: { calc: NumberLong("2555555000000") } } )
162+ db.collection.update( { _id: 10 },
163+ { $inc: { calc: NumberLong(5) } } )
164+
165+ Retrieve the document to verify:
166+
167+ .. code-block:: javascript
168+
169+ db.collection.findOne( { _id: 10 } )
170+
171+ In the returned document, the ``calc`` field contains a
172+ ``NumberLong`` object:
173+
174+ .. code-block:: sh
175+
176+ { "_id" : 10, "calc" : NumberLong("2555555000005") }
162177
163178If 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:
179+ ``NumberLong`` object by a **float** , the data type changes to a
180+ floating point value, as in the following example:
166181
167- #. :operator:`Increment <$inc>` the ``calc`` field:
182+ #. :operator:`Increment <$inc>` the ``calc`` field by ``5`` which the
183+ :program:`mongo` shell treats as a float:
168184
169185 .. code-block:: javascript
170186
171187 db.collection.update( { _id: 10 },
172188 { $inc: { calc: 5 } } )
173189
174- #. Select the updated document:
190+ #. Retrieve the updated document:
175191
176192 .. code-block:: javascript
177193
@@ -182,4 +198,4 @@ as in the following example:
182198
183199 .. code-block:: sh
184200
185- { "_id" : 10, "calc" : 209084588685266560 }
201+ { "_id" : 10, "calc" : 2555555000010 }
0 commit comments