From 7cfca326d8f824d3749ece6ad63a793197bf6c9d Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 16 Apr 2013 14:41:14 -0600 Subject: Full support for arbitrary radixes is in place. It computes the radix and bitwidth dynamically, we could probably speed that up another step by simply having a table of common ones, but for now it'll work for anything. --- src/main.cpp | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 103 insertions(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index d436a20..6674075 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,7 @@ #include "number.h" #include "packedintarray.h" +#include +#include #include using namespace Bu; @@ -169,6 +171,18 @@ void numbertest1() a = "3007103450821050020096034077958224700"; b = "898239467"; + println("%1 / %2 = %3"). + arg( a.toString() ). + arg( b.toString() ). + arg( (a / b).toString() ); + println("%1 %% %2 = %3"). + arg( a.toString() ). + arg( b.toString() ). + arg( (a % b).toString() ); + + a = "983429807324875233421784598754987439873472349875329853298732"; + b = "18446744073709551615"; + println("%1 / %2 = %3"). arg( a.toString() ). arg( b.toString() ). @@ -245,13 +259,101 @@ void numbertestcomp() compcheck( 123, <=, -122 ); } +int getHob( int x ) +{ + for( int j = 31; j >= 0; j-- ) + { + if( x&(1<