Skip to content

Commit 86c1214

Browse files
committed
Add notes on number ranges in Node.js
1 parent 7e876b3 commit 86c1214

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

doc/api.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4021,6 +4021,7 @@ Type Notes](#binddatatypenotes).
40214021
##### <a name="numberhandling"></a> 9.1.6.2 Fetching Numbers
40224022
40234023
By default all numeric columns are mapped to JavaScript numbers.
4024+
Node.js uses double floating point numbers as its native number type.
40244025
40254026
When numbers are fetched from the database, conversion to JavaScript's
40264027
less precise binary number format can result in "unexpected"
@@ -4044,12 +4045,18 @@ purely in Node.js, for example:
40444045
console.log(0.2 + 0.7); // gives 0.8999999999999999
40454046
```
40464047
4048+
Node.js can also only represent numbers up to 2 ^ 53
4049+
which is 9007199254740992. Numbers larger than this will be truncated.
4050+
40474051
The primary recommendation for number handling is to use Oracle SQL or
40484052
PL/SQL for mathematical operations, particularly for currency
4049-
calculations. Alternatively you can use `fetchAsString` or
4053+
calculations.
4054+
4055+
To reliably work with numbers in Node.js, use `fetchAsString` or
40504056
`fetchInfo` (see [below](#fetchasstringhandling)) to fetch numbers in
40514057
string format, and then use one of the available third-party
4052-
JavaScript number libraries that handles more precision.
4058+
JavaScript number libraries that handles large values and more
4059+
precision.
40534060
40544061
##### <a name="datehandling"></a> 9.1.6.3 Fetching Dates and Timestamps
40554062

0 commit comments

Comments
 (0)