dearblue
d983269908
Add mrb_float_to_cstr() MRB_API function
...
In order to share the same operation with `mrb_float_to_str()`,
the internal structure is modified.
2020-04-11 22:11:24 +09:00
David Siaw
b5299b1c58
fix up documentation for values
2019-08-18 20:12:44 +09:00
dearblue
eb86340139
Add constants for floating point number
2019-08-04 18:34:46 +09:00
Yukihiro "Matz" Matsumoto
6f67fddb87
Fix FIXABLE_FLOAT() on MRB_INT64; ref #4566
...
Normal `TYPED_FIXABLE(f,mrb_float)` does not work on 64bit int from
casting problems. The new approach works well, but assumes two's
complement and IEEE-754 floating point numbers.
2019-07-22 13:23:53 +09:00
Yukihiro "Matz" Matsumoto
e941cf06a3
Export mrb_int_value that converts mrb_float to Fixnum.
...
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-21 21:08:26 +09:00
Yukihiro "Matz" Matsumoto
8b8bf9f3f6
Add new functions for numerical operation; ref 237a57b
...
New functions:
* mrb_num_plus(mrb, x, y)
* mrb_num_minus(mrb, x, y)
* num_num_mul(mrb, x, y)
2019-05-20 14:59:25 +09:00
Yukihiro "Matz" Matsumoto
237a57bbe8
Make unused functions private.
...
* mrb_fixnum_plus()
* mrb_fixnum_minus()
* mrb_fixnum_mul()
2019-05-17 11:30:38 +09:00
Yukihiro "Matz" Matsumoto
0c91da257b
Remove unused mrb_num_div() function.
2019-05-17 11:27:21 +09:00
Yukihiro "Matz" Matsumoto
283530b19b
Use mrb_float instead of double in FIXABLE_FLOAT.
2019-05-17 10:37:49 +09:00
YAMAMOTO Masaya
acdc2d1f24
Add MRB_WITHOUT_FLOAT
2017-10-11 17:58:11 +09:00
Tomasz Dąbrowski
f0c1074b07
fix: src\numeric.c(1215): warning C4244: 'function': conversion from 'mrb_int' to 'int', possible loss of data
2017-09-27 22:22:05 +02:00
Yukihiro "Matz" Matsumoto
fc666bfe20
POSFIXABLE and NEGFIXABLE should take one argument.
2017-07-11 09:02:24 +09:00
Yukihiro "Matz" Matsumoto
46dee5716f
Resurrect POSFIXABLE and NEGFIXABLE; ref 9186828
2017-07-10 09:42:48 +09:00
Yukihiro "Matz" Matsumoto
91868286be
FIXABLE_FLOAT() fails sometimes in MRB_INT64 environment.
2017-07-06 09:05:46 +09:00
Yukihiro "Matz" Matsumoto
27a5e10454
Avoid using C++ style comments (//).
2017-05-30 11:47:59 +09:00
Yukihiro "Matz" Matsumoto
83fc915213
Add new range check macro FIXABLE_FLOAT(); ref #3652
...
When MRB_INT64, valid value range of mrb_int is bigger than double,
which only has 53 bits significant precision.
2017-05-26 09:54:10 +09:00
Tomasz Dabrowski
bd2b76ea85
Build fix for 32-bit clang 3.8/3.9 with MRB_INT64
2017-02-16 13:39:21 +01:00
cremno
6369374f79
add mrb_int_mul_overflow(); close #3149
...
- call __builtin_mul_overflow() if it's available
- perform a 64-bit multiplication for 32-bit mrb_int (default)
- otherwise a much slower method is used
2016-05-10 19:10:49 +02:00
cremno
7276e84637
use type-generic checked arithmetic builtins
...
Version checking is not reliable - especially with Clang.
E.g. Apple's Clang (Xcode) uses different version numbers.
A feature check (__has_builtin) is the recommened way.
Add the MRB_HAVE_TYPE_GENERIC_CHECKED_ARITHMETIC_BUILTINS
macro which may be used in other files.
2016-05-09 16:52:57 +02:00
cremno
39b6a9dafc
define macros only if builtins are n/a
2016-05-09 16:34:20 +02:00
Yukihiro "Matz" Matsumoto
065966dae4
common.h are supposed to be included from other header, so call it with quotes; ref #3032
2015-11-28 00:10:38 +09:00
Yukihiro "Matz" Matsumoto
5c405dea3d
include changed from by quotes ("") to by brackets (<>); close #3032
2015-11-27 17:48:23 +09:00
cremno
d109e5b4e1
remove ifdef as MRB_FIXNUM_SHIFT is always defined
2015-11-06 19:27:39 +01:00
Seba Gamboa
a0fe0c40b1
Remove old doxygen tags
2015-10-08 12:29:10 -03:00
Seba Gamboa
40bf7bde78
Sorting documentation grouping
2015-09-21 01:48:42 -03:00
Seba Gamboa
c127614638
Setting up doxygen groups
2015-09-20 21:14:07 -03:00
furunkel
08c877699a
Use builtins for overflow math if possible
2015-04-17 17:37:09 +02:00
cremno
6f893b5183
re-implement mrb_float_to_str()
...
The new implementation is backwards incompatible, but I couldn't find
any usage outside mruby and I also couldn't think of a different and
good name.
All ISO C99 printf conversion specifiers for floating point numbers and
an optional precision are supported.
It is largely based on code from the MIT licensed musl libc
(http://www.musl-libc.org/ ) and its floating point printing is exact
(unlike the current code behind Float#to_s).
2015-02-13 09:33:03 +01:00
Yukihiro "Matz" Matsumoto
206f89e209
add MRB_API modifiers to mruby API functions
2014-08-04 00:47:08 +09:00
cremno
cf8df563c0
add function for checked mrb_int subtraction
2014-05-05 15:28:26 +02:00
cremno
0f39304265
add function for checked mrb_int addition
2014-05-05 15:24:22 +02:00
cremno
ff03cea79b
temporary macros for checked arithmetic functions
2014-05-05 15:22:42 +02:00
Yukihiro "Matz" Matsumoto
514cafe6c3
do not use "to_f" to retrieve floats in mrb_get_args(); close #1965
2014-03-28 11:04:15 +09:00
cremno
61577e8d6b
mrb_flo_to_str: internal linkage
2014-02-18 04:37:35 +01:00
cremno
1838099e00
more mrb_flo_to_str fixes
...
- remove float check (take mrb_float instead of mrb_value)
- support -0.0
- fix range error if log10 is called when n == 0.0
- MSVC older than 2013: add signbit macro (for double)
2014-02-17 12:37:39 +01:00
Yukihiro "Matz" Matsumoto
4b981adc58
remove max_digit from mrb_flo_to_str()
2014-02-17 09:40:30 +09:00
Yukihiro "Matz" Matsumoto
cb5d690ece
cancel f4c27c6 since mruby.h is required for mrb_value etc. anyway
2013-03-30 20:52:51 +09:00
Masaki Muranaka
c260ef894e
Rename mrb_fix2str() to mrb_fixnum_to_str(). This is for naming consistency.
2013-03-29 22:19:26 +09:00
Masaki Muranaka
f4c27c6fb5
Include mrbconf.h as MRB_INT_MAX used here.
2013-03-29 22:19:26 +09:00
Masaki Muranaka
f82ae7653a
Change the second argument of mrb_flo_to_str().
...
Export mrb_flo_to_str() as API.
2013-03-29 22:19:26 +09:00
Masaki Muranaka
710f625254
Remove mrb_flt2big() as there is no bignum in the core.
...
Add new API mrb_flo_to_fixnum(). You can replace mrb_flt2big() to mrb_flo_to_fixnum() with few modifications.
2013-03-29 22:19:26 +09:00
Masaki Muranaka
a01e968cdb
Remove limits.h from numeric.h. Add limits.h to some C files.
2013-03-29 10:06:40 +09:00
Yukihiro Matsumoto
265fa03d2c
defining mrb_int also requires MRB_INT_{MAX,MIN} to be defined
2012-10-17 00:40:23 +09:00
Yukihiro Matsumoto
7d02df3016
NaN boxing
2012-08-14 13:16:34 +09:00
Masaki Muranaka
7ac4b56141
Remove unimplemented declarations.
2012-07-29 20:35:23 +09:00
Yukihiro Matsumoto
db3d72a471
move RSHIFT from numeric.h to numeric.c
2012-06-13 15:40:41 +09:00
Yukihiro Matsumoto
6a5019d37f
optimized OP_{ADD,SUB,MUL,DIV} to use numeric function for fixnums to handle overflow
2012-06-13 15:38:18 +09:00
Yukihiro Matsumoto
a4d3579e31
add extern "C" guards; close #126
2012-05-18 02:02:49 +09:00
Yukihiro Matsumoto
470da1eda0
redefine POST/NEG FIXABLE using INT_MIN/MAX
2012-05-17 09:32:23 +09:00
Yukihiro Matsumoto
f4cf8ea423
partial VC support
2012-05-09 08:49:38 +09:00