kirill-stepanishin commented on code in PR #3427:
URL: https://github.com/apache/tinkerpop/pull/3427#discussion_r3289918746


##########
docs/src/reference/gremlin-variants.asciidoc:
##########
@@ -1969,15 +1970,67 @@ g.V().hasLabel('person').groupCount().by('age')
 Either of the above two options accomplishes the desired goal as both prevent 
`groupCount()` from having to process
 the possibility of `null`.
 
+[[gremlin-javascript-numeric-types]]
+=== Numeric Types
+
+JavaScript has a single `Number` type (IEEE 754 double) which cannot 
distinguish between JVM numeric types. The driver
+provides typed wrapper classes and factory functions that give explicit 
control over serialization and deserialization.
+
+==== Controlling Serialization
+
+Wrapping a value selects the GremlinLang type suffix and GraphBinary type code 
sent to the server. Without wrappers the
+driver infers types automatically, so existing code is unaffected.
+
+[source,javascript]
+----
+const { toLong, toInt, toFloat, toDouble, toShort, toByte } = 
gremlin.structure;
+
+g.V().has('age', toInt(29)).next();
+g.V().has('score', toFloat(3.14)).next();
+g.V().has('id', toLong('9007199254740993')).next();
+----
+
+`toLong()` accepts `number`, `string`, or `bigint`. String and bigint inputs 
support the full signed 64-bit range;
+number inputs must be within the safe integer range.

Review Comment:
   If a JS number outside safe range is added, it throws a `RangeError`. Users 
can still pass the value as a string or bigint to get the full 64-bit range 
(`toLong('9007199254740993')`), so I think throwing is fair given they've opted 
into precise mode.
   I'm not too firm on it though, I'm happy to change it if you feel it makes 
more sense. For now I added a sentence in the docs explaining the behaviour.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to