View/Edit #132:product mult*iply

Switch to edit mode.

Name(s): product mult*iply
1:  {@bignums} = args
2:  decoded = {}
3:  for x in (bignums)
4:    decoded = {@decoded, $list_utils:reverse(decode_binary(x, 1))}
5:  endfor
6:  result_digits = $list_utils:make(length(decoded[1]) + length(decoded[2]))
7:  for x in [1..length(decoded[1])]
8:    for y in [1..length(decoded[2])]
9:      result_digits[x + y - 1] = result_digits[x + y - 1] + decoded[1][x] * decoded[2][y]
10:     $command_utils:suspend_if_needed()
11:   endfor
12: endfor
13: for x in [1..length(result_digits) - 1]
14:   result_digits[x + 1] = result_digits[x + 1] + result_digits[x] / 256
15:   result_digits[x] = result_digits[x] % 256
16:   $command_utils:suspend_if_needed()
17: endfor
18: while (result_digits && result_digits[$] == 0)
19:   result_digits[$..$] = {}
20: endwhile
21: return encode_binary($list_utils:reverse(result_digits))
22: "Last modified by manta (#7165) on Sat Mar  3 20:50:43 2001 MST."
23: "This verb previously owned by manta (#7165), and chowned to $slacker upon dewizarding (Sat Aug 17 14:50:05 2002 MDT)."
24: "Last modified by Dax (#789) on Sat Aug 17 14:50:05 2002 MDT."

Verb arguments: this none this
Verb perms: Readable eXecutable NOT-Debug
Verb owned by: Slacker (#55)

You are not logged in.

[home | help | who | search | setup | code]