diff options
author | Marius Kintel <marius@kintel.net> | 2012-01-08 17:31:09 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2012-01-08 17:31:09 (GMT) |
commit | c08f3afbbb76948f3c142dfac57d6663c0d102b3 (patch) | |
tree | fb415fbe048cf2af447ee2fecc51983ef4213841 /src/func.cc | |
parent | e271e958dcb09bfa2e02866e87a88a12c7464f91 (diff) |
bugfix: Infinite loop in deg2rad/rad2deg when giving it an inf number, e.g. 1/0. Reported by Triffid Hunter.
Diffstat (limited to 'src/func.cc')
-rw-r--r-- | src/func.cc | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/func.cc b/src/func.cc index 1138173..6686cb9 100644 --- a/src/func.cc +++ b/src/func.cc @@ -96,24 +96,14 @@ std::string BuiltinFunction::dump(const std::string &indent, const std::string & return dump.str(); } -static double deg2rad(double x) +static inline double deg2rad(double x) { - while (x < 0.0) - x += 360.0; - while (x >= 360.0) - x -= 360.0; - x = x * M_PI * 2.0 / 360.0; - return x; + return x * M_PI / 180.0; } -static double rad2deg(double x) +static inline double rad2deg(double x) { - x = x * 360.0 / (M_PI * 2.0); - while (x < 0.0) - x += 360.0; - while (x >= 360.0) - x -= 360.0; - return x; + return x * 180.0 / M_PI; } Value builtin_abs(const Context *, const std::vector<std::string>&, const std::vector<Value> &args) |