Hi.

I am writing an emulation program for an old computer - An Olivetti Programma 101, the first computer I ever encountered when I was in high school and which really sparked my interest and probably changed my life. The 101 had quite a few unique and very clever features and used a system of 22 digit registers. I had started writing some code to do the same functions as the 101 supported in serial BCD representation covering add, subtract, multiply, divide (including remainder) and square root. I had the add and subtract routines working when I came across this post. With just a couple of extra things this library will do nicely. I need to know the length of the whole part of the number and the length of the fractional part.

The number.c and corresponding number.h seem best suited despite the more arcane calling process although using the BigNumber functionality certainly makes the process easy and logical. Good work all round. If I have read the code correctly the information I want is the n_len and n_scale of the target number.

Now I have to admit my C++ is pretty flaky and I don't tend to write libraries or use the macro capability of C much. I recognise the power of it but am not very familiar. But I thought I had it by studying what was there and doing something similar. First I added a routine bc_size_whole_fraction to number.c as follows:

`void `

bc_size_whole_fraction (num, size_whole, size_fraction)

bc_num num;

int *size_whole;

int *size_fraction;

{

size_whole = num->n_len;

size_fraction = num->n_scale;

}

I thought this would take the number in question and return the size of the whole part and the faction part. Next I changed number.h as follows:

.

.

.

_PROTOTYPE(void bc_out_num, (bc_num num, int o_base, void (* out_char)(int),

int leading_zero));

/* new line below*/

_PROTOTYPE(void bc_size_whole_fraction, (bc_num num, int *size_whole, int *size_fraction));

#endif

Finally I took a fragment of one of the test programs with just the multiply part so I could play around with it:

#include "number.h" // this is the modified file as is number.c

static int DIGITS=1;

void print_bignum (bc_num x)

{

char *s=bc_num2str(x);

Serial.print (s);

free(s);

}

void setup ()

{

Serial.begin (9600); // I am using a Mega 1280 at 9600 baud.

Serial.println ();

Serial.println ();

bc_init_numbers (); // initialize library

int sizew,sizef;

// some big numbers

bc_num a=NULL, b = NULL, c = NULL;

Serial.println ("--- multiply ---");

// test multiplication

bc_str2num(&a, "42.345",DIGITS);

bc_str2num(&b, "18254546", DIGITS);

bc_multiply(a,b,&c,DIGITS);

// get results as string

bc_size_whole_fraction(a,&sizew,&sizef); // read the sizes I am seeking for number a

Serial.print("int ="); Serial.print(sizew); Serial.print(" "); Serial.print(sizef); Serial.print(" ");

print_bignum (a); Serial.println();

print_bignum (b); Serial.println();

print_bignum (c); Serial.println();

bc_free_num (&b);

bc_free_num (&c);

} // end of setup

void loop () { }

Now when complied i receive quite a series of errors:

sketch_jul06a.cpp.o: In function `print_bignum(bc_struct*)':

C:\DOCUME~1\Fred\LOCALS~1\Temp\build325333058827944339.tmp/sketch_jul06a.cpp:11: undefined reference to `bc_num2str(bc_struct*)'

sketch_jul06a.cpp.o: In function `setup':

C:\DOCUME~1\Fred\LOCALS~1\Temp\build325333058827944339.tmp/sketch_jul06a.cpp:21: undefined reference to `bc_init_numbers()'

C:\DOCUME~1\Fred\LOCALS~1\Temp\build325333058827944339.tmp/sketch_jul06a.cpp:31: undefined reference to `bc_str2num(bc_struct**, char const*, int)'

C:\DOCUME~1\Fred\LOCALS~1\Temp\build325333058827944339.tmp/sketch_jul06a.cpp:32: undefined reference to `bc_str2num(bc_struct**, char const*, int)'

C:\DOCUME~1\Fred\LOCALS~1\Temp\build325333058827944339.tmp/sketch_jul06a.cpp:33: undefined reference to `bc_multiply(bc_struct*, bc_struct*, bc_struct**, int)'

C:\DOCUME~1\Fred\LOCALS~1\Temp\build325333058827944339.tmp/sketch_jul06a.cpp:37: undefined reference to `bc_size_whole_fraction(bc_struct*, int*, int*)'

C:\DOCUME~1\Fred\LOCALS~1\Temp\build325333058827944339.tmp/sketch_jul06a.cpp:43: undefined reference to `bc_free_num(bc_struct**)'

C:\DOCUME~1\Fred\LOCALS~1\Temp\build325333058827944339.tmp/sketch_jul06a.cpp:44: undefined reference to `bc_free_num(bc_struct**)'

I am thinking this is an error which is readily fixed and caused by something I missed and can't see. Any suggestions?

Regards, Fred.