ionspin / kotlin-multiplatform-bignum

A Kotlin multiplatform library for arbitrary precision arithmetics
Apache License 2.0
345 stars 41 forks source link

BingNumber(str: String) is missing #207

Closed sergeych closed 2 years ago

sergeych commented 2 years ago

It is not just a convenient feature, it is a compatibility issue. The current set of constructors do not let effectively add one, as there is 2 parameters that should come out from parse function at once. So I;d recommend introduce data class like BigNumber.CreationParams(arighmetic,sign) and whatever else might be useful in future, making addition of the string parsing constructor relatively easy by simple refactoring parseString() code to provide such creation params first. Also, I could not build the project from sources as serialization dependency is missing. Thanks in advance.

sergeych commented 2 years ago

You can do it also nu including something like:

fun BigInteger(text: String): BigInteger = BigInteger.parseString(text)

in your distribution

ionspin commented 2 years ago

Hi @sergeych,

it is a compatibility issue

Could you expand on what is it that this library is expected to be compatible with?

Also, I could not build the project from sources as serialization dependency is missing.

The automated builds were successful, and the serialization is kotlinx-serialization version 1.3.1 which is published by jetbrains, could you please share the logs you are seeing?

ionspin commented 2 years ago

Closed by accident, apologies for noise.

sergeych commented 2 years ago

compatibility with Java's BigInteger. I've started to port massive portions of our code to your multiplaform solutions and found it is a little different, while it could be almost a drop in replacement for java BigInteger. Why did you mark it invalid? You suppose source-compatibility with java's biginteger/bigdecimal is invalid?

ionspin commented 2 years ago

I think I marked it as invalid because BigNumber is an interface so it cant have constructors.

sergeych commented 2 years ago

Oh, I see it now. Thanks for clarifying.