Giter Site home page Giter Site logo

Bitwise operators about bignumber.js HOT 5 CLOSED

ashrafsabrym avatar ashrafsabrym commented on June 11, 2024
Bitwise operators

from bignumber.js.

Comments (5)

MikeMcl avatar MikeMcl commented on June 11, 2024

Hello ashrafsabrym,
No plans to implement bitwise operations but I may look into it shortly.

from bignumber.js.

blixt avatar blixt commented on June 11, 2024

@MikeMcl Have you considered implementing bitwise operators since this issue was created?

from bignumber.js.

MikeMcl avatar MikeMcl commented on June 11, 2024

@blixt
The problem is that a bignumber is stored in a decimal floating point format, so there are no binary digits (bits) to operate on.

The value of a bignumber would first need to be converted to base 2, but, as I'm sure you are aware, that would only make sense for integers as many non-integer decimal numbers can't be represented exactly in binary.

new BigNumber(0.2).toString(2)    // 0.00110011001100110011...    

It doesn't seem appropriate to me to include methods in the library that only operate on integers, and I am not sure there is enough demand for this to justify the added code that would be necessary.

Having said that, you are the second person to mention this issue, so there is some demand, but can you give any examples of how it would be useful to be able to perform bitwise operations on bignumbers.

from bignumber.js.

blixt avatar blixt commented on June 11, 2024

Right, and I also realized you store the data as strings which makes the whole thing difficult. I created my own implementation intended for integers only, which uses a binary backing store: https://github.com/blixt/js-bigint

from bignumber.js.

noorfathima11 avatar noorfathima11 commented on June 11, 2024

Implementing bitwise operations is essential since BigInt has it, but for many purposes where exponents may be considered switching between BigNumber and BigInt is resource heavy.

from bignumber.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.