Description
In JavaScript, the Number type cannot safely represent integer values larger than 2^53^. This limitation has forced developers to use inefficient workarounds and third-party libraries. BigInt is a new data type intended to fix that.
This can be very useful to sport exact precision currency.
Also with the pending introduction of CAS and Atomic counters which both use 64 bit values the use of BigInt seems to a natural fit. However ti appear that the Eventing transpiler will not allow syntax like :
function OnUpdate(doc, meta) {
|
var mybigint = 2n;
|
log('docId', meta.id); |
}
|
If we trigger on mutation on the above we get an "Unexpected Illegal Token".
Yet the Eventing JavaScript Google V8 engine does indeed support BigInt operations like:
function OnUpdate(doc, meta) {
|
var max = BigInt(2) ** BigInt(64) - BigInt(1); |
log('E1 max unsigned 64-bit number',max.toString()); |
// 18446744073709551615n |
}
|
The above works as expected with the new BigInt extension e.g. in the V8 runner
2020-04-18T08:46:33.902-07:00 [INFO] "E1 max unsigned 64-bit number" "18446744073709551615"
|
Important Fix Note:
The bugfix for this issue is intertwined with MB-38843 fix. These two bugs must be handled together as a single unit
Attachments
Issue Links
For Gerrit Dashboard: MB-38844 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
126094,1 | MB-38844: Scan for BigInt notation while scanning numeric values | unstable | eventing | Status: ABANDONED | -1 | 0 |
126726,5 | MB-38844: Use v8 compiler to compile handler code | unstable | eventing | Status: MERGED | +2 | +1 |