To create arbitrary BigInts via the C++ API, use BigInt::NewFromWords.

An alternative, as you suggest, is to parse the string as source, because
"BigInt strings with 'n' suffixes" are BigInt literals. Instead of "eval",
the API functions to do that are Script::Compile and Script::Run. Look at
samples/shell.cc or test/cctest/* for examples.

Another alternative, depending on your requirements, might be to create
this custom "parser" (more of a wrapper, really) in JavaScript:

function MyBigInt(str) {
  console.assert(str.endsWith("n"));
  return BigInt(str.substring(0, str.length - 1));
}


On Sat, Sep 15, 2018 at 8:44 PM J Decker <d3c...@gmail.com> wrote:

>
>
> On Sat, Sep 15, 2018 at 8:41 PM J Decker <d3c...@gmail.com> wrote:
>
>> I was implementing a parser that includes BigInt strings with 'n'
>> suffixes...
>> I tried to create a BigInt::New( isolate, ...  and then found the only
>> constructor takes an int64; which isn't a very big int.
>>
>> howto bigint from string?
>>
>
> maybe someone could share a snippet to call eval()?  Also Date::New()
> doesn't take a string :(
>
>
>> --
>> --
>> v8-users mailing list
>> v8-users@googlegroups.com
>> http://groups.google.com/group/v8-users
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "v8-users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to v8-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> --
> v8-users mailing list
> v8-users@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to v8-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to