mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-27 13:34:19 -04:00
Improved binary multiplication for large numbers
This commit is contained in:
parent
f655eabc12
commit
8bb4d2ce86
6 changed files with 41 additions and 125 deletions
|
@ -115,6 +115,26 @@ void binary_subtract(short int accumulator[], short int input_buffer[]) {
|
|||
binary_add(accumulator, sub_buffer);
|
||||
}
|
||||
|
||||
void binary_multiply(short int reg[], char data[]) {
|
||||
/* Multiply the contents of reg[] by a number */
|
||||
short int temp[112] = {0};
|
||||
short int accum[112] = {0};
|
||||
int i;
|
||||
|
||||
binary_load(temp, data, strlen(data));
|
||||
|
||||
for (i = 0; i < 102; i++) {
|
||||
if (temp[i] == 1) {
|
||||
binary_add(accum, reg);
|
||||
}
|
||||
shiftup(reg);
|
||||
}
|
||||
|
||||
for (i = 0; i < 112; i++) {
|
||||
reg[i] = accum[i];
|
||||
}
|
||||
}
|
||||
|
||||
void shiftdown(short int buffer[]) {
|
||||
int i;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue