Jeroen van Rijn
5c95a48bc7
Clean up core:math/big
...
- Deprecate the u64/u32 implementation so we can use fewer nails and have an easier time of maintaining and optimizing the package going forward. The remaining implementation still works on 32-bit targets, it's just a smidge less efficient.
- Use only 1 nail instead of 4. The tests now run 3.5% faster as a result.
Future optimizations may including using fully packed backing (no nails) using `intrinsics.overflow_*` to handle borrow and carry safely.
2026-02-15 17:00:53 +01:00
Jeroen van Rijn
d8f2eb2717
Remove core:mem import from core:math/big.
2026-02-12 14:37:28 +01:00
Jeroen van Rijn
8ed264680b
Remove all core:os imports from JS targets
...
Fix `local_tz_name` on FreeBSD.
2026-02-09 15:07:27 +01:00
Jeroen van Rijn
9c1a9c80f8
core:os -> core:os/os for core:math/big
2026-02-08 12:42:28 +01:00
Jeroen van Rijn
976bb52af7
Always use new itoa method when MATH_BIG_FORCE_32_BIT
2025-11-28 23:08:17 +01:00
Jeroen van Rijn
be38ba58b3
Another little bit faster.
2025-11-27 18:27:55 +01:00
Jeroen van Rijn
3cdaf06fc8
Switch between old and new itoa method based on optimization level + digit size
2025-11-27 16:10:32 +01:00
Jeroen van Rijn
1ea5990be2
Speed up big.itoa
...
Extract 18 (64-bit) or 8 (32-bit) digits per big division.
This gives a 2.5x speedup for a 1024-bit bigint.
2025-11-27 15:35:05 +01:00
gingerBill
78d8059ebe
Use @(rodata) where possible
2025-11-27 10:24:22 +00:00
gingerBill
c63fa3f663
Use < 0 instead of == -1 for comparisons
2025-11-27 09:13:21 +00:00
gingerBill
53876907c6
Handle Allocator_Error correctly in core:math/big
2025-11-27 09:10:03 +00:00
gingerBill
842cfee0f3
Change Odin's LICENSE to zlib from BSD 3-clause
...
This change was made in order to allow things produced with Odin and using Odin's core library, to not require the LICENSE to also be distributed alongside the binary form.
2025-10-28 14:38:25 +00:00
Jeroen van Rijn
c4c2431997
Package lines for core:math and more.
2025-10-09 19:56:21 +02:00
Jeroen van Rijn
9dafd77bc0
Turn core:math/bìg tests into regular core:testing tests.
...
`core:math/big` has been verified against Python's big integer implementation long enough.
Turn it into a regular regression test using the `core:testing` framework, testing against
a generated corpus of test vectors.
2025-06-11 00:40:52 +02:00
Barinzaya
d402b7408d
Fix a range check in int_atoi in core:math/big.
...
The check seems to have been assuming that rune comparisons are
unsigned, but they're signed. This was causing an assertion failure for
certain input characters (anything with an ASCII value less than
'+'/43).
2025-05-24 11:31:37 -04:00
Feoramund
70820c2c40
Add missing string_to_int alias in core:math/big
2024-06-09 21:42:31 -04:00
Laytan
d7fdccb08c
fix a couple of -vet-style failures after f54977336b
2024-05-09 19:39:48 +02:00
gingerBill
3e7e779abf
Replace core:* to base:* where appropriate
2024-01-28 22:18:51 +00:00
gingerBill
9b54b99bf6
Use positional and named arguments within the core library
2023-06-21 01:17:05 +01:00
gingerBill
c85ac955f7
Simplify docs to hide the copyright
2022-01-17 19:00:47 +00:00
gingerBill
2800d4b8d0
Merge branch 'master' into optional-semicolons
2021-09-06 16:46:57 +01:00
Jeroen van Rijn
de5d897b5c
Add internal_int_(pack, unpack).
2021-09-06 12:57:48 +02:00
Jeroen van Rijn
3faac14d62
big: Add ASCII file import/export.
2021-09-05 15:50:23 +02:00
Jeroen van Rijn
31918d3b8f
big: Add internal_int_is_prime.
2021-09-02 18:31:08 +02:00
Jeroen van Rijn
65a15e9c06
big: Add internal_int_exponent_mod.
2021-09-01 19:13:47 +02:00
gingerBill
720884e0f1
Strip even more semicolons if followed by a } or ) on the same line
2021-08-31 23:47:57 +01:00
gingerBill
251da264ed
Remove unneeded semicolons from the core library
2021-08-31 22:21:13 +01:00
Jeroen van Rijn
852643e6ba
Add tests for `internal_int_is_square'.
2021-08-28 13:27:46 +02:00
Jeroen van Rijn
23d29be4d8
big: Update license to BSD-3.
2021-08-19 12:12:59 +02:00
gingerBill
c27b8a71fd
Replace err != nil with or_return where appropriate
2021-08-15 17:52:10 +01:00
Jeroen van Rijn
851780b8f4
big: Add arguments and usage to test.py.
2021-08-11 20:59:54 +02:00
Jeroen van Rijn
6c681b258c
big: Add _private_int_sqr_comba.
2021-08-11 20:59:54 +02:00
Jeroen van Rijn
1f91a2fe65
big: Finish refactor.
2021-08-11 20:59:54 +02:00
Jeroen van Rijn
1ebb0bd9d6
big: More refactoring.
2021-08-11 20:59:54 +02:00
Jeroen van Rijn
9890e7cfeb
big: Improved zero_unused helper.
2021-08-11 20:59:53 +02:00
Jeroen van Rijn
463003e86a
bit: Improved bitfield extraction.
2021-08-11 20:59:53 +02:00
Jeroen van Rijn
97d80d03f9
big: Error.None -> nil
2021-08-11 20:59:52 +02:00
Jeroen van Rijn
e80ac18324
big: Add factorial, have tests use hex strings.
2021-08-11 20:59:52 +02:00
Jeroen van Rijn
74258a170a
big: fix itoa base PoT other than 16.
2021-08-11 20:59:51 +02:00
Jeroen van Rijn
2fbff25a18
big: Improve int_bitfield_extract.
2021-08-11 20:59:51 +02:00
Jeroen van Rijn
2aae1016ab
big: Add sqrt.
2021-08-11 20:59:51 +02:00
Jeroen van Rijn
9c2468ecf7
big: Add atoi.
2021-08-11 20:59:51 +02:00
Jeroen van Rijn
0a431eef19
big: Add another way to estimate radix size.
2021-08-11 20:59:51 +02:00
Jeroen van Rijn
1ebaa9fb3b
big: itoa now works for arbitrary radixes.
2021-08-11 20:59:51 +02:00
Jeroen van Rijn
d953e40fb3
big: Add pow.
2021-08-11 20:59:51 +02:00
Jeroen van Rijn
7648f2e655
big: Finish big ZII refactor.
2021-08-11 20:59:50 +02:00
Jeroen van Rijn
d9efa6c8b5
big: More ZII refactoring.
2021-08-11 20:59:50 +02:00
Jeroen van Rijn
2e372b33a3
big: More ZII refactoring.
2021-08-11 20:59:50 +02:00
Jeroen van Rijn
4eadd0867d
big: Continuing to refactor.
2021-08-11 20:59:50 +02:00
Jeroen van Rijn
9dba17cf87
bigint: refactor to big.Int instead of bigint.Int.
2021-08-11 20:59:50 +02:00