Yukihiro "Matz" Matsumoto
d73e337442
mruby-bigint: update README.md
...
The document is written by Google Jules.
2025-06-23 17:07:20 +09:00
John Bampton
781edbd446
misc: fix spelling
2025-05-14 02:01:02 +10:00
Yukihiro "Matz" Matsumoto
baea6e284e
mruby-bigint (mpz_bits): use lzb()
2025-04-17 08:11:27 +09:00
Yukihiro "Matz" Matsumoto
061521ead5
mruby-bigint (mpz_bits): renamed from mpz_bit_length()
2025-04-17 08:10:34 +09:00
Yukihiro "Matz" Matsumoto
16198dc985
mruby-numeric-ext (int_sqrt): translate Japanese comment (oops)
2025-04-17 01:43:03 +09:00
Yukihiro "Matz" Matsumoto
ddfe65763e
mruby-numeric-ext (int_sqrt): support bigint
2025-04-16 23:08:23 +09:00
Yukihiro "Matz" Matsumoto
82522a2e71
mruby-bigint (mrb_bint_to_s): add check for MRB_32BIT and MRB_INT64
2025-04-14 22:09:33 +09:00
Yukihiro "Matz" Matsumoto
9750513c25
mruby-bigint (mpz_get_str): add type cast to stop warning
2025-04-04 23:55:44 +09:00
dearblue
3b1e3d930f
Hide mpz_and() symbol
2025-02-02 16:59:28 +09:00
Yukihiro "Matz" Matsumoto
c83bddd856
mruby-bigint (bint_new): avoid memcpy'ing NULL pointer
...
The second argument of memcpy() is declared to never be NULL. Clang ASAN
report this as an undefined behavior error.
2024-12-18 13:48:11 +09:00
Hoshiumi Arata
03ed952600
Merge branch 'master' into tests_for_bigint
2024-12-13 17:31:54 +09:00
Yukihiro "Matz" Matsumoto
b561abd46b
Merge pull request #6457 from hoshiumiarata/fix_division_of_smallint_by_bigint
2024-12-13 14:23:52 +09:00
Hoshiumi Arata
6fb93ce6f7
mruby-bigint: fix bug with division of a small number by a bigint; fix #6456
2024-12-13 12:07:34 +09:00
Yukihiro "Matz" Matsumoto
29a2bc19a3
mruby-bigint (mpz_get_str): use UL suffix for mp_limb table
2024-12-12 17:15:02 +09:00
Hoshiumi Arata
3152402fa6
Merge branch 'master' into tests_for_bigint
2024-12-12 17:01:06 +09:00
Yukihiro "Matz" Matsumoto
423c12e985
Merge pull request #6455 from hoshiumiarata/bigint_fix_div_rounding
2024-12-12 16:13:47 +09:00
Yukihiro "Matz" Matsumoto
d8e6de28e9
mruby-bigint (mrb_bint_add_n): fixed a memory leak
2024-12-11 21:29:22 +09:00
Yukihiro "Matz" Matsumoto
8bd62ca311
mruby-bigint (mrb_bint_xor): fix a bug in bigint ^ int operation
...
Fix #6453 ; ref #6444
2024-12-11 21:29:21 +09:00
Yukihiro "Matz" Matsumoto
b807c0a27d
mruby-bigint (mpz_pow): combine mpz_init and mpz_set
2024-12-11 21:29:21 +09:00
Yukihiro "Matz" Matsumoto
8da0db545e
mruby-bigint (mpz_get_str): reduce one division
2024-12-11 21:29:21 +09:00
Hoshiumi Arata
94a3a3eb6e
mruby-bigint: fix rounding behavior in mpz_mdiv and mpz_mdivmod functions
2024-12-11 21:09:46 +09:00
Hoshiumi Arata
7dfbbd1eaa
Merge branch 'master' into tests_for_bigint
2024-12-09 22:38:32 +09:00
Yukihiro "Matz" Matsumoto
9af061a4ce
mruby-bigint: fixed a bug in string conversion; ref #6444
2024-12-09 13:14:22 +09:00
Yukihiro "Matz" Matsumoto
6d2e7f50e2
mruby-bigint: compact mpz_add_int,mpz_sub_int calling conditions
2024-12-09 13:04:01 +09:00
Yukihiro "Matz" Matsumoto
441d4be0ad
mruby-bigint: fixed a bug with bigint +/- mrb_int; close #6445
2024-12-08 23:45:25 +09:00
Hoshiumi Arata
21ccbf965e
bigint: expand test cases for arithmetic operations
2024-12-04 18:34:21 +09:00
dearblue
de494796ac
Fixed typo
2024-11-20 21:14:55 +09:00
Yukihiro "Matz" Matsumoto
dc5566e560
mruby-bigint (int_fit_limb_p): fix the logic to check mrb_int size
...
`int_fit_limb_p()` checks if `mrb_int` fits in `mp_limb`. Previous logic
did not work well with negative integers.
2024-11-20 11:27:54 +09:00
Yukihiro "Matz" Matsumoto
fed631c21b
mruby-bigint (mrb_bint_sub_n): avoid allocating mpz_z
2024-11-05 13:03:54 +09:00
Yukihiro "Matz" Matsumoto
6085ffb968
mruby-bigint (mrb_bint_add_n): avoid allocating mpz_z
2024-11-05 12:22:10 +09:00
Yukihiro "Matz" Matsumoto
ef18bd86a6
mruby-bigint (mpz_sub_int): avoid allocating mpz_t for mrb_int
2024-11-05 11:52:22 +09:00
Yukihiro "Matz" Matsumoto
fe12e840f3
mruby-bigint (mpz_add_int): move the function definition
...
To prepare `mpz_sub_int` update.
2024-11-05 11:52:22 +09:00
Yukihiro "Matz" Matsumoto
19d3620965
mruby-bigint (mrb_bint_powm): stop a warning for no return
2024-10-31 14:06:10 +09:00
Yukihiro "Matz" Matsumoto
f245943aed
mruby-bigint (mrb_bint_powm): fixed bugs in type casting
2024-10-24 07:21:12 +09:00
Yukihiro "Matz" Matsumoto
0b96f7f2f7
mruby-bigint (mrb_bint_to_s): add uzero_p() check
2024-10-24 07:20:24 +09:00
Yukihiro "Matz" Matsumoto
c5565a37ac
mruby-bigint: add checks for divided by zero by sizes and contents
2024-10-24 07:18:34 +09:00
Yukihiro "Matz" Matsumoto
5e9593e285
mruby-bigint (udiv): add assertion for divided by zero
2024-10-24 07:16:32 +09:00
Yukihiro "Matz" Matsumoto
11cff8fa7d
mruby-bigint (mpz_init_set_str): should skip + in the string
...
When the string starts with `+` it should not cause error silently. It
might cause serious error afterwards.
2024-10-22 14:44:51 +09:00
Yukihiro "Matz" Matsumoto
f3257c448b
mruby-bigint (mrb_bint_powm): should call mpz_clear() on exceptions
2024-10-19 13:09:03 +09:00
Yukihiro "Matz" Matsumoto
e4d2f343fe
mruby-bigint (mrb_bint_neg): move the function to group bit operations
2024-10-19 12:47:06 +09:00
Yukihiro "Matz" Matsumoto
ee13b9e67b
mruby-bigint: fix mrb_int optimization bugs for and, or, xor
...
If the operand is a small integer, those functions tried to reduce
bigint allocations, but we had some bugs in them. We removed those
imperfect optimization altogether.
2024-10-19 12:45:04 +09:00
Yukihiro "Matz" Matsumoto
2430eaba13
mruby-bigint (mrb_bint_powm): fixed memory leak
2024-10-19 07:32:06 +09:00
Yukihiro "Matz" Matsumoto
001d5fcc3f
mruby-bigint (mpz_get_str): get b2 by table lookup
...
The `b2` is the power of `base` no bigger than DIG_BASE.
2024-10-19 07:32:05 +09:00
Yukihiro "Matz" Matsumoto
4aa87acfc9
mruby-bigint (mpz_set_uint64): adjust reallocation size for uint64
...
The uint64_t value may fit in `mp_limb*n` where n is 1..4.
2024-10-19 07:32:05 +09:00
Yukihiro "Matz" Matsumoto
5e6d382782
mruby-bigint (mpz_set_uint64): fixed a bug in for loop
...
Found double increments in a loop. Since no one called mpz_set_int64()
in the real code, we could not find this bug for long time.
2024-10-18 12:27:02 +09:00
Yukihiro "Matz" Matsumoto
fe42f1d047
mruby-bigint (mpz_set_int): simplify using early return
2024-10-18 12:27:02 +09:00
Yukihiro "Matz" Matsumoto
a5c0b2114a
mruby-bigint (mrb_bint_2comp): need to initialize mpz_t
2024-10-18 12:27:02 +09:00
Yukihiro "Matz" Matsumoto
f1863163a8
mruby-bigint (uzero_p): avoid signed and unsigned comparison in loop
2024-10-16 16:33:43 +09:00
Yukihiro "Matz" Matsumoto
b5801cd730
mruby-bigint (mrb_bint_new_int64): fixed a bug on the 32bit platforms
2024-10-11 14:19:33 +09:00
Yukihiro "Matz" Matsumoto
f4fdf25bb0
mruby-bigint (mrb_bint_new_int64): wrong return value
2024-10-11 08:41:51 +09:00