For my project I need to set a string to a BigNumber using the BigNumber library, how would I do that?
toInt won't work for it, so I need another way. The error message is "Conversion from 'String' to non-scalar type 'BigNumber' requested"
Any suggestions?
Thanks
I suggest looking at the sizes of various numbers and see if they can accomodate the size of you number
int = 16 bits
unit32_t = 32 bits
unit64_t = 64 bits
Maybe not, but the library appears to have a toString function judging by the examples
// function to display a big number and free it afterwards
void printBignum (BigNumber & n)
{
char * s = n.toString ();
Serial.println (s);
free (s);
} // end of printBignum
A BigNumber is a structure, and that function pulls out a printable ASCII C-string representing the number itself.
The library is mostly C, and exclusively uses C-strings.
typedef struct bc_struct
{
sign n_sign;
int n_len; /* The number of digits before the decimal point. */
int n_scale; /* The number of digits after the decimal point. */
int n_refs; /* The number of pointers to this number. */
bc_num n_next; /* Linked list for available list. */
char *n_ptr; /* The pointer to the actual storage.
If NULL, n_value points to the inside of
another number (bc_multiply...) and should
not be "freed." */
char *n_value; /* The number. Not zero char terminated.
May not point to the same place as n_ptr as
in the case of leading zeros generated. */
} bc_struct;