Integers vs Numbers

Open
#91 17 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
30/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp, node.js
Domain
api, performance

Research direction

No files or tests are named. Start by reviewing the N-API number-creation interface and the issue's discussion about V8 integer versus double performance; done requires a clear decision on whether integer creation or an integer hint is supported and what API change or documentation would be needed.

Written by the indexing model from the issue text.

Description

Even if javascript makes no difference, V8 can distinguish integers from double for performance reason (looping with a double is a huge loss because the looping variable can't be a cpu register).
I could create numbers that are integers in C++ but now, with N-API, I see no way to create integers, but just doubles.
Isn't this a performance problem?
Is there any way to hint the API to use integers instead?

Dominant language
C++
Stars
2.6k
Forks
602
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nodejs/node-addon-examples

All issues in nodejs/node-addon-examples

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.