Commit Graph

90 Commits

Author SHA1 Message Date
Jeroen van Rijn
a7bf06eb5f Fix cast. 2026-02-15 17:15:48 +01:00
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
71f343bc85 Remove core:mem import from core:math/big. 2026-02-12 13:56: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
Jeroen van Rijn
56aab55d82 Fix #5931
Fix #5931 and add test case for it.
2025-11-18 15:37:57 +01: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
gingerBill
8b860da2eb Remove unused import 2025-08-08 12:12:08 +01:00
gingerBill
7642e0a0e0 Require @(init) and @(fini) to be proc "contextless" () 2025-08-08 12:10:01 +01: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
gingerBill
8642d719f0 Imply #no_capture to all variadic parameters 2024-07-14 12:19:47 +01:00
gingerBill
c7bd954752 Add more uses of #no_capture 2024-07-14 11:56:04 +01:00
gingerBill
149ecafdef Remove the need for rand in core:math/big 2024-06-15 15:43:57 +01:00
Jeroen van Rijn
908a6ff2d4 Elide unnecessary condition 2024-06-14 21:34:05 +02:00
Josh Jones
759139089f Fix big.shrink not actually shrinking 2024-06-14 19:58:13 +02:00
Laytan
d7fdccb08c fix a couple of -vet-style failures after f54977336b 2024-05-09 19:39:48 +02:00
Ed Yu
dd74a57c44 Expose internal invmod and int_exponent_mod with more consistent naming 2024-03-12 11:01:09 -07:00
Jeroen van Rijn
db03c86544 Fix typo in big.internal_invmod
Fixes #3253
2024-03-08 18:05:34 +01:00
Ed Yu
de41c2256d For invmod, b has to be > 1, fix a logic typo 2024-03-04 10:16:19 -08:00
gingerBill
3e7e779abf Replace core:* to base:* where appropriate 2024-01-28 22:18:51 +00:00
Jeroen van Rijn
f79efd43e4 Fix missing clamp in core:math/big random. 2023-11-27 12:43:24 +01:00
gingerBill
3dec55f009 Replace x in &y Use &v in y syntax through core & vendor for switch/for statements 2023-06-26 15:42:57 +01:00
FancyKillerPanda
62ff8daa78 Changed //+ignore to //+build ignore. 2022-02-24 12:23:54 +11:00
gingerBill
fb01dfe048 Improve docs_writer.cpp 2022-01-17 22:17:07 +00:00
gingerBill
c85ac955f7 Simplify docs to hide the copyright 2022-01-17 19:00:47 +00:00
Jeroen van Rijn
938744b276 [math/big] Rename internal_int_shl_digit to _private_int_shl_leg.
Same for the SHR variant. These are pure implementation details to shift by a leg/word at a time.
Prevent accidental usage.
2021-12-11 15:22:24 +01:00
Jeroen van Rijn
c771ea9794 Merge pull request #1358 from Kelimion/big_math_fix
[math/big] Return 0, .Integer_Underflow if T = unsigned and bigint is negative.
2021-12-09 16:41:37 +01:00
gingerBill
94bad4d786 Merge branch 'master' of https://github.com/odin-lang/Odin 2021-12-09 15:36:12 +00:00
gingerBill
1e17d5d86f Add utility procedures to get low values 2021-12-09 15:34:35 +00:00
Jeroen van Rijn
b2b79b86f0 [math/big] Return 0, .Integer_Underflow if trying to get a negative number to an unsigned int. 2021-12-09 16:31:54 +01:00
Jeroen van Rijn
c94098c2ab [math/big] Fix int_set and int_get. 2021-12-09 16:14:04 +01:00
gingerBill
87952fdb8e big.Rat (Experimental) 2021-10-29 12:40:54 +01:00
gingerBill
5006674a9b Correct math/big 2021-09-08 13:14:13 +01:00
gingerBill
ca33cb990b Strip semicolons in core which were missing 2021-09-08 13:12:38 +01:00
gingerBill
2800d4b8d0 Merge branch 'master' into optional-semicolons 2021-09-06 16:46:57 +01:00
Jeroen van Rijn
1f5ce91ae2 big: Add internal_random_prime. 2021-09-05 10:40:35 +02:00
Jeroen van Rijn
f2c5c26f2c big: Add internal_int_prime_next_prime. 2021-09-04 16:31:05 +02:00
Jeroen van Rijn
b1ed7fc6b9 big: Add Lucas-Selfridge. 2021-09-03 23:54:54 +02:00
Jeroen van Rijn
70e12f7a1c big: Fix internal_int_mod for inputs with opposite signs.
This threw off Frobenius-Underwood.
2021-09-03 14:50:26 +02:00
Jeroen van Rijn
eecc786bd2 big: Add Frobenius-Underwood. 2021-09-03 01:25:18 +02:00
Jeroen van Rijn
31918d3b8f big: Add internal_int_is_prime. 2021-09-02 18:31:08 +02:00
Jeroen van Rijn
ae354731ed big: Add ; after proc map. 2021-09-01 19:18:13 +02:00
Jeroen van Rijn
671b413b15 big: Use new comparison helpers. 2021-09-01 19:13:47 +02:00
Jeroen van Rijn
335d361fc6 big: Add comparison helpers. 2021-09-01 19:13:47 +02:00
Jeroen van Rijn
2110778040 big: Add internal_int_exponent_mod_fast. 2021-09-01 19:13:47 +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
f57201bbd1 Remove unneeded semicolons from the core library 2021-08-31 22:32:53 +01:00