Skip to content

Commit

Permalink
libs/math: support fmod function
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed Sep 14, 2021
1 parent 803c094 commit 18fb1b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libs/math.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func init() {
"modf": types.NewIdent(cpkg+".Modf", c.FuncTT(doubleT, doubleT, c.PtrT(doubleT))),
"modff": types.NewIdent(cpkg+".Modff", c.FuncTT(floatT, floatT, c.PtrT(floatT))),
"ldexp": types.NewIdent("math.Ldexp", c.FuncTT(doubleT, doubleT, c.Go().Int())),
"fmod": types.NewIdent("math.Mod", c.FuncTT(doubleT, doubleT, doubleT)),
"M_PI": types.NewIdent("math.Pi", doubleT),
},
}
Expand Down Expand Up @@ -92,6 +93,7 @@ func init() {
buf.WriteString("double modf(double x, double *iptr);\n")
buf.WriteString("float modff(float value, float *iptr);\n")
buf.WriteString("double ldexp(double x, _cxgo_go_int exp);\n")
buf.WriteString("double fmod(double x, double exp);\n")
lib.Header = buf.String()
return lib
})
Expand Down
2 changes: 2 additions & 0 deletions libs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ void foo(float x, double y) {
x = roundf(x); y = round(y);
x = fabsf(x); y = fabs(y);
x = powf(x, x); y = pow(y, y);
y = fmod(y, y);
}
`,
exp: `
Expand All @@ -110,6 +111,7 @@ func foo(x float32, y float64) {
y = math.Abs(y)
x = math32.Pow(x, x)
y = math.Pow(y, y)
y = math.Mod(y, y)
}
`,
},
Expand Down

0 comments on commit 18fb1b5

Please sign in to comment.