Умножение: Общий случай

This commit is contained in:
2022-05-12 18:59:27 +03:00
parent de4142353d
commit 3b797f0215
2 changed files with 77 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
# Умножение: общий случай
## Ссылка на видеоразбор
## Код из книги
let real_mul x y n =
let n2 = n + 2 in
let r = n2 / 2 in
let s = n2 r in
let xr = x(r)
and ys = y (s) in
let p = log2 xr
and q = log 2 ys in
if p = 0 & q = 0 then Int 0 else
let k = q + r + 1
and l = p + s + 1
and m = p + q + 4 in
(x(k) / y(l)) ndiv ( Int 2 / Int m) ;;