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

Unified Diff: runtime/vm/bigint_operations.cc

Issue 8351050: Print Bigints in decimal format. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/bigint_operations.h ('k') | runtime/vm/bigint_operations_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/bigint_operations.cc
===================================================================
--- runtime/vm/bigint_operations.cc (revision 1042)
+++ runtime/vm/bigint_operations.cc (working copy)
@@ -220,6 +220,23 @@
}
+const char* BigintOperations::ToDecCString(const Bigint& bigint,
+ uword (*allocator)(intptr_t size)) {
+ return ToDecCString(bigint.BNAddr(), allocator);
+}
+
+
+const char* BigintOperations::ToDecCString(const BIGNUM *bn,
+ uword (*allocator)(intptr_t size)) {
+ char* str = BN_bn2dec(bn);
cshapiro 2011/11/02 00:19:01 BN has historically used an inefficient algorithm
sra1 2011/11/02 03:10:23 It might be fun to write the b^(n*2^i) algorithm i
+ intptr_t length = strlen(str) + 1; // '\0'-terminated.
+ char* result = reinterpret_cast<char*>(allocator(length));
+ memmove(result, str, length);
+ OPENSSL_free(str);
+ return result;
+}
+
+
const char* BigintOperations::ToHexCString(const Bigint& bigint,
uword (*allocator)(intptr_t size)) {
return ToHexCString(bigint.BNAddr(), allocator);
« no previous file with comments | « runtime/vm/bigint_operations.h ('k') | runtime/vm/bigint_operations_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698