dartcoin / dart-bitcoin

Bitcoin library written in Google Dart (dartlang.org).
http://dartcoin.org
MIT License
33 stars 17 forks source link

Consider changing all Bitcoin amounts to BigInteger #12

Closed stevenroose closed 10 years ago

stevenroose commented 10 years ago

I've been starting it here in this branch:

https://github.com/stevenroose/dartcoin-lib/tree/bigint-satoshi

izaera commented 10 years ago

Is this a new bigint you are writing? El 04/04/2014 02:02, "Steven Roose" notifications@github.com escribió:

I've been starting it here in this branch:

https://github.com/stevenroose/dartcoin-lib/tree/bigint-satoshi

— Reply to this email directly or view it on GitHubhttps://github.com/dartcoin/dartcoin-lib/issues/12 .

stevenroose commented 10 years ago

No, I abandoned that idea. I'd like to have a BigInteger implemented like in Java, but as you pointed out that it's license is a problem, I just left it as it is.

This is just a consideration to use BigInt's instead of ints for expressing amounts in Bitcoin.

What's your opinion on that, these values range from -1 to 2.1*10^15. That's higher than 2^32 but should fit in JS's artificial 2^53 integer space. On Apr 4, 2014 7:18 AM, "Ivan Zaera" notifications@github.com wrote:

Is this a new bigint you are writing? El 04/04/2014 02:02, "Steven Roose" notifications@github.com escribió:

I've been starting it here in this branch:

https://github.com/stevenroose/dartcoin-lib/tree/bigint-satoshi

Reply to this email directly or view it on GitHub< https://github.com/dartcoin/dartcoin-lib/issues/12> .

Reply to this email directly or view it on GitHubhttps://github.com/dartcoin/dartcoin-lib/issues/12#issuecomment-39532699 .

izaera commented 10 years ago

Dart numbers implementation is a total mess (AKA crap) so I don't know what to recommend. If you are concerned about speed, though, take into account that BigInteger is quite slow (many orders of magnitude slower than int).

For example, I tried to use BigInteger for 64 bit values and ended up implementing them with two 32 bit ints which are managed with functions like: mul64, div64 and so on. It's all in fixnum.dart, if you want to peek.

stevenroose commented 10 years ago

Maybe you should promote the existence of that library a bit more. Like putting it in the dartist repo. (I don't really know what it is intended for but it seems like a good place to publish general-purpose libs.

I think I'll stick to the built-in integers, that makes using the library for lighter use a lot easier. On Apr 4, 2014 1:27 PM, "Ivan Zaera" notifications@github.com wrote:

Dart numbers implementation is a total mess (AKA crap) so I don't know what to recommend. If you are concerned about speed, though, take into account that BigInteger is quite slow (many orders of magnitude slower than int).

For example, I tried to use BigInteger for 64 bit values and ended up implementing them with two 32 bit ints which are managed with functions like: mul64, div64 and so on. It's all in fixnum.dart, if you want to peek.

Reply to this email directly or view it on GitHubhttps://github.com/dartcoin/dartcoin-lib/issues/12#issuecomment-39555346 .

izaera commented 10 years ago

You mean promoting fixnum? Naaah. I put it inside src folder in cipher because I don't want to maintain a new more API. One is enough ;-).

It's just a few functions to clip and operate with numbers. Not enough to make a lib of it.

stevenroose commented 10 years ago

We'll stick to using the regular int type.