Giter Club home page Giter Club logo

Comments (3)

jjrv avatar jjrv commented on September 26, 2024

This is probably because size_t is a 64-bit integer on your system and JavaScript has no equivalent type. There are 3 options to convert to on the JavaScript side:

  • Double, dropping the low bits. That still gives you 53 bits so in many real-world cases it would never get rounded.
  • 32-bit integer, dropping the high bits.
  • An object holding two 32-bit parts and a toString method outputting the 64-bit number in base 10.

All of these have their own dangers and inefficiencies. Best might be to allow setting a global policy and overriding it per-function in the bindings. It will take a while to do. Maybe for now it would be best to convert to double and warn about it?

from nbind.

bsergeev avatar bsergeev commented on September 26, 2024

Good point!
I'll switch to uint32_t and will check that my size_t values never exceed its MAX.

from nbind.

jjrv avatar jjrv commented on September 26, 2024

Nowadays size_t should be supported, see 64-bit integers.

from nbind.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.