Git Product home page Git Product logo

Comments (5)

dcodeIO avatar dcodeIO commented on September 23, 2024

While it would be nice being able to do so, toString is a relatively expensive operation. One could see the absence of such a feature as a hint that one shouldn't implicitly and repetitively convert longs to strings without being aware of its cost. protobuf.js for example expects this behavior.

from long.js.

sm2017 avatar sm2017 commented on September 23, 2024

Can you explain why toString is experience? I have to use it too much . I want know more about it . may be I change my approach

For example how can I save a Long id in a pouchdb database and run a query sort by id?? Is it possible without toString??

from long.js.

dcodeIO avatar dcodeIO commented on September 23, 2024

That's because toString uses div (ref). One way for storage could be to generate an 8 byte binary string using the first 4 bytes for the high and the second 4 bytes for the low bits - that is if the database supports ASCII or another properly sortable column type (won't work with utf8, doesn't work well with signage). Alternatively, the result of toString could be reused where applicable instead of calling it multiple times on the same instance.

from long.js.

sm2017 avatar sm2017 commented on September 23, 2024

What about fromString , is fromString experience? and fromBits?

from long.js.

dcodeIO avatar dcodeIO commented on September 23, 2024

Closing this issue for now as it hasn't received any replies recently. Feel free to reopen it if necessary!

from long.js.

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.