Skip to content

Add support to java.lang.BigInteger to the polyglot Value API #2737

Open

Description

Image for: Description

BigInteger is a type that is available not only in Java but also (at least) JavaScript. The current polyglot API already allows getting a polyglot numeric type with the Value class but nothing is available to do so for BigInteger.

For example I'd like to have a way to safely read this js variable:

let bigInteger = 
  // this is the same as Java Long.MAX_VALUE
  BigInt(9223372036854775807)
  // ensure that we go over the limits of Long
  + 1n;

Then on a polyglot API:

// some argument we get in interop mode that contains
// the variable described above
Value argument ...

// read it:
BigInteger bi = argument.asBigInteger();

I guess that a fitsInBigInteger() would be useless to have.

Metadata

Image for: Metadata

Metadata

Image for: Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

Image for: Issue actions