Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Issue 8351050: Print Bigints in decimal format. (Closed)

Created:
9 years, 1 month ago by srdjan
Modified:
9 years, 1 month ago
Reviewers:
sra1, cshapiro, siva
CC:
reviews_dartlang.org
Visibility:
Public.

Description

Print Bigints in decimal format. Committed: https://code.google.com/p/dart/source/detail?r=1058

Patch Set 1 #

Patch Set 2 : '' #

Patch Set 3 : '' #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+126 lines, -3 lines) Patch
M runtime/vm/bigint_operations.h View 1 chunk +6 lines, -0 lines 0 comments Download
M runtime/vm/bigint_operations.cc View 1 2 1 chunk +17 lines, -0 lines 2 comments Download
M runtime/vm/bigint_operations_test.cc View 1 chunk +101 lines, -0 lines 0 comments Download
M runtime/vm/object.cc View 1 chunk +1 line, -1 line 0 comments Download
M runtime/vm/object_test.cc View 1 chunk +1 line, -2 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
srdjan
9 years, 1 month ago (2011-11-01 21:27:29 UTC) #1
siva
lgtm
9 years, 1 month ago (2011-11-02 00:09:42 UTC) #2
cshapiro
DBC http://codereview.chromium.org/8351050/diff/2009/runtime/vm/bigint_operations.cc File runtime/vm/bigint_operations.cc (right): http://codereview.chromium.org/8351050/diff/2009/runtime/vm/bigint_operations.cc#newcode231 runtime/vm/bigint_operations.cc:231: char* str = BN_bn2dec(bn); BN has historically used ...
9 years, 1 month ago (2011-11-02 00:19:01 UTC) #3
sra1
9 years, 1 month ago (2011-11-02 03:10:23 UTC) #4
DBC

http://codereview.chromium.org/8351050/diff/2009/runtime/vm/bigint_operations.cc
File runtime/vm/bigint_operations.cc (right):

http://codereview.chromium.org/8351050/diff/2009/runtime/vm/bigint_operations...
runtime/vm/bigint_operations.cc:231: char* str = BN_bn2dec(bn);
On 2011/11/02 00:19:01, cshapiro wrote:
> BN has historically used an inefficient algorithm for binary to decimal
> conversion.  Should we replace BN, a faster algorithm, such as the one used by
> GMP, would be preferable.
> 
>
http://www.gnu.org/software/gmp/manual/html_mono/gmp.html#Binary%2520to%2520R...

It might be fun to write the b^(n*2^i) algorithm in Dart, selecting n such that
b^n is a Smi.
You would need to have simple access to
(1) a Smi test
(2) some approximate comparison to tell if x*x > v without doing the
multiplication (number of bits/bytes/words).
(3) a divide producing both quotient and remainder

If the output is some kind of stream (.writeOn) instead of a string, you can
generate and the high digits before the low digits are ready.
If you are happy to over-allocate by 1 character, a string can be generated
without copying.

Powered by Google App Engine
This is Rietveld 408576698