summaryrefslogtreecommitdiffhomepage
path: root/src/numeric.c
AgeCommit message (Collapse)Author
2019-05-30Fix inverted compilation condition; fix #4478Yukihiro "Matz" Matsumoto
2019-05-21Update ISO section number for some Numeric methods.Yukihiro "Matz" Matsumoto
2019-05-21Export `mrb_int_value` that converts `mrb_float` to `Fixnum`.Yukihiro "Matz" Matsumoto
Or `Float` if `mrb_float` value is too big (or too small) to fit in `mrb_int`. The `_int_` in `mrb_int_value` means `Integral` module, which represents integer-like values in mruby.
2019-05-21Silence the return value warnings from gcc; ref 237a57bYukihiro "Matz" Matsumoto
2019-05-21Move `**`,`/`,`quo`,`div` and comparison methods to Integral from NumericKOBAYASHI Shuji
Having these methods in Numeric can get in the way of creating subclasses of Numeric because they only support Fixnum and Float.
2019-05-20Add new functions for numerical operation; ref 237a57bYukihiro "Matz" Matsumoto
New functions: * mrb_num_plus(mrb, x, y) * mrb_num_minus(mrb, x, y) * num_num_mul(mrb, x, y)
2019-05-18Move `Numeric#__coerce_step_counter` to `Integral`KOBAYASHI Shuji
This method is only used in `Integral#step`
2019-05-17Make unused functions private.Yukihiro "Matz" Matsumoto
* mrb_fixnum_plus() * mrb_fixnum_minus() * mrb_fixnum_mul()
2019-05-17Remove unused `mrb_num_div()` function.Yukihiro "Matz" Matsumoto
2019-05-17Move `Numeric#div` to the core.Yukihiro "Matz" Matsumoto
2019-05-17Make `flo_rount` to return `Integeral`.Yukihiro "Matz" Matsumoto
2019-05-17Change the `num.divmod(float)` to return `[int,num]`.Yukihiro "Matz" Matsumoto
2019-05-17Add a new function `mrb_int_value`.Yukihiro "Matz" Matsumoto
This function returns `Fixnum` if the value fits in `mrb_int`, otherwise it returns `Float` value (mruby behavior of handling integers).
2019-05-17Use `int64_t` instead of `mrb_int` in `int64_value`.Yukihiro "Matz" Matsumoto
2019-05-16Terminate float right shift if shift value is too big.Yukihiro "Matz" Matsumoto
2019-05-02Unify overflow error class for conversion to integer to `RangeError`KOBAYASHI Shuji
2019-04-15Fixed wrong function names; fix #4380Yukihiro "Matz" Matsumoto
2019-04-08Fix C99 style inline declaration; fix #4365Yukihiro "Matz" Matsumoto
2019-03-21Fix `Float#eql?`KOBAYASHI Shuji
2019-01-16Avoid runtime evaluation for `MRB_WITHOUT_FLOAT`KOBAYASHI Shuji
2019-01-13Improve compatibility to CRuby for `Float#to_s`KOBAYASHI Shuji
Bfore: Float::INFINITY.to_s #=> "inf" 50.0.to_s #=> "50" 1e20.to_s #=> "1e+20" After / CRuby: Float::INFINITY.to_s #=> "Infinity" 50.0.to_s #=> "50.0" 1e20.to_s #=> "1.0e+20"
2019-01-10Remove duplicate code in numeric.cKOBAYASHI Shuji
2019-01-04Integrate mrblib/float.rb into src/numeric.cKOBAYASHI Shuji
- Avoid hack for `MRB_WITHOUT_FLOAT` in build scripts - Avoid runtime dispatch for `MRB_WITHOUT_FLOAT`
2018-12-17Recover `#to_int`; ref #4177Yukihiro "Matz" Matsumoto
We have removed implicit conversion to strings using `to_int`. But some users still using `to_int` as a typical integer method, i.e. they do string check by code like: `obj.respond_to?(:to_int)`. So we have recovered the method.
2018-11-19Remove implicit conversion using `to_int` method.Yukihiro "Matz" Matsumoto
The ISO standard does not include implicit type conversion using `to_int`. This implicit conversion often causes vulnerability. There will be no more attacks like #4120. In addition, we have added internal convenience method `__to_int` which does type check and conversion (from floats).
2018-09-07Clear terminated spacedearblue
2018-08-06Small refactoring of `flodivmod()`.Yukihiro "Matz" Matsumoto
2018-05-01Update `MRB_FLO_TO_STR_FMT` to "%.16g"; fix #4016Yukihiro "Matz" Matsumoto
2017-11-22Provide shortcut comparison methods for numbers for performance.Yukihiro "Matz" Matsumoto
2017-11-04Merge branch 'master' of github.com:mruby/mrubyYAMAMOTO Masaya
2017-10-17Add `Numeric#{finite?,infinite?}`; CRuby2.4Yukihiro "Matz" Matsumoto
2017-10-11Add MRB_WITHOUT_FLOATYAMAMOTO Masaya
2017-09-27fix: src\numeric.c(1215): warning C4244: 'function': conversion from ↵Tomasz Dąbrowski
'mrb_int' to 'int', possible loss of data
2017-09-27fix: src\numeric.c(954): warning C4334: '<<': result of 32-bit shift ↵Tomasz Dąbrowski
implicitly converted to 64 bits (was 64-bit shift intended?)
2017-09-27fix: src\numeric.c(897): warning C4244: 'function': conversion from ↵Tomasz Dąbrowski
'mrb_int' to 'mrb_float', possible loss of data
2017-09-02Trying to make the source code more understandable by removing mixing of ↵Flavio Medeiros
ternary if statements with attributions.
2017-08-22Remove possible path that leaves a local variable uninitialized.Yukihiro "Matz" Matsumoto
2017-08-10Remove redundant `flo_hash` function.Yukihiro "Matz" Matsumoto
`flo_hash` implemented `15.2.8.3.18` but `Kernel#hash` (15.3.1.3.15) now works for numbers.
2017-08-08Float values divided by zero should honor signs; fix #3766Yukihiro "Matz" Matsumoto
It also fixes unexpected resurrection of #3745 by #3752
2017-07-26`(0).div(0.0)` should be NaN; fix #3754Yukihiro "Matz" Matsumoto
2017-07-25`(0.0).div(0)` should not be infinity; fix #3753Yukihiro "Matz" Matsumoto
2017-07-05Avoid undefined behavior of left shifting negative integer; #3728Yukihiro "Matz" Matsumoto
2017-06-17Use `mrb_int` instead of `int`.Yukihiro "Matz" Matsumoto
2017-05-31Avoid infinite loop on negative exponent; fix #3677Yukihiro "Matz" Matsumoto
2017-05-27Fixed rounding functions (round,ceil,floor,truncate) in MRB_INT64.Yukihiro "Matz" Matsumoto
They didn't work well with inexact numbers (inf,nan). Fix #3671
2017-05-26Add new range check macro FIXABLE_FLOAT(); ref #3652Yukihiro "Matz" Matsumoto
When MRB_INT64, valid value range of mrb_int is bigger than double, which only has 53 bits significant precision.
2017-05-26Fix indentation in mrb_init_numeric()Yukihiro "Matz" Matsumoto
2017-05-26fixup! Let Fixnum#{ceil,floor,round,truncate} to return itself; #3652Yukihiro "Matz" Matsumoto
2017-05-26Let Fixnum#{ceil,floor,round,truncate} to return itself; #3652Yukihiro "Matz" Matsumoto
2017-05-26Try our own `ipow()` if both base and exp are fixnums; fix #3652Yukihiro "Matz" Matsumoto