Giter VIP home page Giter VIP logo

Comments (13)

srknzl avatar srknzl commented on August 19, 2024 1

Ok I can do that for you. That change will probably be in 1.1.1 release.

from bigdecimal.js.

srknzl avatar srknzl commented on August 19, 2024 1

You can always open a pr to any repository as I know. You just need to fork the repository and then create your branch there.

Unfortunately, I have finalized my fix see #25. It includes an optimization too. Using BigInt constructors seemed to degrade performance of abs and compare functions, I solved the issue by caching some BigInts. Of course, I appreciate contributions but I saw your message too late for this one. Sorry :)

from bigdecimal.js.

srknzl avatar srknzl commented on August 19, 2024 1

1.1.1 is released https://www.npmjs.com/package/bigdecimal.js/v/1.1.1

from bigdecimal.js.

macdonaldr93 avatar macdonaldr93 commented on August 19, 2024

I think I found the issue. It has to do with 1n and numbers like that: https://github.com/srknzl/bigdecimal.js/blob/main/src/bigdecimal.ts#L3638

from bigdecimal.js.

srknzl avatar srknzl commented on August 19, 2024

Investigating, thanks for the issue.

from bigdecimal.js.

srknzl avatar srknzl commented on August 19, 2024

BigInt literals like 1n are supported in 16.13.0 as you can see from https://node.green/#ES2020-features-BigInt-basic-functionality I can clone and run your example in your library with Node 16.13.

Obviously, this library requires a JS runtime that has BigInt. Also, this library is intended to be used with Node.js. When using react native, runtime is not nodejs anymore.

It looks like react native's runtime (as I understand JavaScriptCore and maybe something else on android) does not have BigInt support yet. Check out:

https://forum.dfinity.org/t/cant-find-variable-bigint-in-expo-react-native/5706

and

facebook/react-native#28492

Looks like you can import and inject big-integer library as BigInt in your shim.js if BigInt does not exist in your react native runtime. Check out https://github.com/Balanced02/BigIntIssue for an example project.

from bigdecimal.js.

srknzl avatar srknzl commented on August 19, 2024

I suggest you to use big.js or other bigdecimal libraries if you need bigdecimal feature in environments where BigInt does not exist. My library's difference from big.js is the usage of BigInt and better performance for most operations due to that. Thank you for your understanding.

from bigdecimal.js.

macdonaldr93 avatar macdonaldr93 commented on August 19, 2024

I used the BigInt shim and it worked perfectly. I tested big ints in Android and it was all good. Sadly, it doesn't polyfill the literal. So I think if your library used BigInt(1) instead of 1n, it would work. I could try patching that in your library actually.

from bigdecimal.js.

macdonaldr93 avatar macdonaldr93 commented on August 19, 2024

Woohoo :) Thanks.

from bigdecimal.js.

macdonaldr93 avatar macdonaldr93 commented on August 19, 2024

I'm testing out the patch this morning on my library too. I'll report back shortly.

from bigdecimal.js.

macdonaldr93 avatar macdonaldr93 commented on August 19, 2024

I can confirm it works now. Not using a bigint literal and polyfilling BigInt with this is the solution.

import BigInt from 'big-integer';

if (typeof global.BigInt === 'undefined') {
  global.BigInt = BigInt;
}

from bigdecimal.js.

macdonaldr93 avatar macdonaldr93 commented on August 19, 2024

I have a branch ready to go, if you want. I'd love to contribute to this library :) I think you just need to enable access for me to open a pull request.

from bigdecimal.js.

macdonaldr93 avatar macdonaldr93 commented on August 19, 2024

Wow, that's awesome. It looks like it actually increased the performance a decent amount. Happy it worked it out :) Thanks for your help.

from bigdecimal.js.

Related Issues (9)

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.