diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-08-03 16:35:31 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-08-03 16:35:31 +0900 |
| commit | c480ac4457d026593c50f6c2704ac74f9255b2f0 (patch) | |
| tree | e8a0de917ca35f1360bf8c2f439bed1ddabcf173 /mrbgems/mruby-numeric-ext | |
| parent | e75572af6a6a286546879eef89c053a7a7fe8ad9 (diff) | |
| download | mruby-c480ac4457d026593c50f6c2704ac74f9255b2f0.tar.gz mruby-c480ac4457d026593c50f6c2704ac74f9255b2f0.zip | |
numeric_ext.c: `modulo` and `remainder` should handle infinite argument.
Diffstat (limited to 'mrbgems/mruby-numeric-ext')
| -rw-r--r-- | mrbgems/mruby-numeric-ext/src/numeric_ext.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/mrbgems/mruby-numeric-ext/src/numeric_ext.c b/mrbgems/mruby-numeric-ext/src/numeric_ext.c index fb8ea53b1..59b51d092 100644 --- a/mrbgems/mruby-numeric-ext/src/numeric_ext.c +++ b/mrbgems/mruby-numeric-ext/src/numeric_ext.c @@ -83,6 +83,7 @@ int_remainder(mrb_state *mrb, mrb_value x) mrb_float n = (mrb_float)a; mrb_float m = mrb_as_float(mrb, y); + if (isinf(m)) return mrb_float_value(mrb, n); return mrb_float_value(mrb, n-m*trunc(n/m)); } #endif @@ -97,6 +98,7 @@ flo_remainder(mrb_state *mrb, mrb_value self) a = mrb_float(self); mrb_get_args(mrb, "f", &b); if (b == 0) zerodiv(mrb); + if (isinf(b)) return mrb_float_value(mrb, a); return mrb_float_value(mrb, a-b*trunc(a/b)); } #endif |
