Skip to content

bignum_from_string not works on odd nbytes #25

@minocoko

Description

@minocoko

`
char buffer[500];
struct bn a, b, c;

bignum_from_string(&a, "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe", 64);
bignum_to_string(&a, buffer, 500);
printf("%s\n", buffer);

bignum_from_int(&b, 3);

bignum_add(&a, &b, &c);
bignum_to_string(&c, buffer, 500);
printf("%s\n", buffer);

`

length of "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe" is 63
if I change 64 to 63 and comment out
// require((nbytes & 1) == 0, "string format must be in hex -> equal number of bytes"); // require((nbytes % (sizeof(DTYPE) * 2)) == 0, "string length must be a multiple of (sizeof(DTYPE) * 2) characters");

that code works correct

PR created: #26

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions