Giter Site home page Giter Site logo

purescript-bigints's People

Contributors

dependabot[bot] avatar gbagan avatar jacereda avatar jamesdbrock avatar kl0tl avatar matthewleon avatar megamaddu avatar paulyoung avatar proclivis avatar radrow avatar sharkdp avatar sigma-andex avatar thomashoneyman avatar triallax avatar unisay avatar xertrov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

purescript-bigints's Issues

use NonEmptyString

Would be nice to have the output of various functions here be NonEmptyStrings.

toBase

At the moment, its possible to parse a string representation of a base-n encoded number using fromBase :: Int -> String -> BigInt

However, its not currently possible to go other way around, from BigInt to its base-n representation (only decimal base is supported via toString)

So, having a method toBase :: Int -> BigInt -> String would be quite useful and make things isomorphic.

'big-integer' should be dependency

Hi,
I'm using a purescript module that depends on your purescript-bigints. Somewhere along the line, on a clean install, I'm missing the npm big-integer package. I guess that purescript-bigints depends on having the underlying 'big-integer' package installed? If so, it may be useful to list it as a dependency.

zshr

I realize that this is probably only missing because there isn’t an equivalent function in big-integer but I’m wondering if it could be defined in terms of the existing functions.

Add LICENSE file?

MIT is implicit in bower.json, but I think it would be great to have a license file too.

Conversion to Maybe Int

How can I convert BigInt to Int when I am sure that it fits in the boundaries? It would be nice to have a function for that toInt :: BigInt -> Maybe Int that would degrade BigInt to primitive Int if the conversion is possible

fromNumber is unsafe

For example, fromNumber infinity. Does it make sense to change it to fromNumber :: Number -> Maybe BigInt?

Prim.Partial ?

fromJust returns Prim.Partial, which is not a recognized type.

Example: fromJust (fromString "864854875498476985798759875076")

Parsing an empty string succeeds and returns zero

This appears to be by design in the underlying JavaScript library (emphasis mine):

You can create a bigInt by calling the bigInt function. You can pass in

  • a string, which it will parse as an bigInt and throw an "Invalid integer" error if the parsing fails.
  • a Javascript number, which it will parse as an bigInt and throw an "Invalid integer" error if the parsing fails.
  • another bigInt.
  • nothing, and it will return bigInt.zero.

The stage 3 draft BigInt specification for ES requires this too:

EDITOR'S NOTE
StringToBigInt("") is 0n according to the logic in 3.1.3.1.

This is not what I would do if it were up to me, but since this library is mostly just a binding to the underlying JavaScript library, perhaps the best way forward is to leave this as-is and clarify this behaviour in the documentation?

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.