MCPcopy Create free account
hub / github.com/codr7/hacktical-c / hc_fix_add

Function hc_fix_add

fix/fix.c:52–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52hc_fix_t hc_fix_add(const hc_fix_t x, const hc_fix_t y) {
53 const uint8_t xe = hc_fix_exp(x);
54 const uint8_t ye = hc_fix_exp(y);
55
56 if (xe == ye) {
57 return hc_fix(xe, hc_fix_val(x) + hc_fix_val(y));
58 }
59
60 return hc_fix(xe, hc_fix_val(x) +
61 hc_fix_val(y) * hc_scale(xe) / hc_scale(ye));
62}
63
64hc_fix_t hc_fix_sub(const hc_fix_t x, const hc_fix_t y) {
65 const uint8_t xe = hc_fix_exp(x);

Callers 2

test_addFunction · 0.85
fix_benchmarksFunction · 0.85

Calls 4

hc_fix_expFunction · 0.85
hc_fixFunction · 0.85
hc_fix_valFunction · 0.85
hc_scaleFunction · 0.85

Tested by 1

test_addFunction · 0.68