Skip to content

Commit 6dfec43

Browse files
committed
DOCS-948 incorporate kristina's feedback
1 parent 43ddc51 commit 6dfec43

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

source/core/shell-types.txt

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,35 +143,51 @@ NumberLong
143143

144144
By default, the :program:`mongo` shell treats all numbers as
145145
floating-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

148148
The ``NumberLong()`` constructor accepts the long as a string:
149149

150150
.. code-block:: javascript
151151

152-
NumberLong("20908458868526654")
152+
NumberLong("2090845886852")
153153

154154
The following examples use the ``NumberLong()`` class to write to the
155155
collection:
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

163178
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:
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

Comments
 (0)