You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since Integers can be larger than can be represented as JavaScript numbers, it is only safe to convert Integer instances to JavaScript numbers if you know that they will not exceed `(2`<sup>`53`</sup>` - 1)` in size:
161
+
Since Integers can be larger than can be represented as JavaScript numbers, it is only safe to convert to JavaScript numbers if you know that they will not exceed `(2`<sup>`53`</sup>` - 1)` in size.
162
+
In order to facilitate working with integers the driver include `neo4j.isInt`, `neo4j.integer.inSafeRange`, `neo4j.integer.toNumber`, and `neo4j.integer.toString`.
162
163
163
164
```javascript
164
165
var aSmallInteger =neo4j.int(123);
165
-
var aNumber =aSmallInteger.toNumber();
166
+
if (neo4j.integer.inSafeRange(aSmallInteger)) {
167
+
var aNumber =aSmallInteger.toNumber();
168
+
}
166
169
```
167
170
168
-
If you will be handling integers larger than that, you can use the Integer instances directly, or convert them to strings:
171
+
If you will be handling integers larger than that, you can should convert them to strings:
169
172
170
173
```javascript
171
174
var aLargerInteger =neo4j.int("9223372036854775807");
172
-
var integerAsString =aLargerInteger.toString();
175
+
if (!neo4j.integer.inSafeRange(aSmallInteger)) {
176
+
var integerAsString =aLargerInteger.toString();
177
+
}
173
178
```
174
179
175
-
To help you work with Integers, the Integer class exposes a large set of arithmetic methods.
176
-
Refer to the [Integer API docs](http://neo4j.com/docs/api/javascript-driver/current/class/src/v1/integer.js~Integer.html) for details.
0 commit comments