1
考慮到以下浮點數除法程式: (fdiv.c)
#include <stdio.h>
#include <stdlib.h>
double divop(double orig, int slots) {
if (slots == 1 || orig == 0)
return orig;
int od = slots & 1;
double result = divop(orig / D1, od ? (slots + D2) >> 1 : slots >> 1);
if (od)
result += divop(result, slots);
return result;
}
假設 divop()
的第二個參數必為大於 0
的整數,而且不超過 int
型態能表達的數值上界。請補完程式碼。
作答區
D1
= ?
(a)
1(b)
2(c)
3(d)
4D2
= ?
(a)
1(b)
2(c)
3(d)
4or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up