Commit Graph

313 Commits

Author SHA1 Message Date
Andrew Kelley
126c9a34af restructure unit test to be easier to debug 2024-05-08 19:37:29 -07:00
Андрей Краевский
7cc0e6d4cd
std: fix big int llshr to respect aliasing (#19612) 2024-04-13 03:06:23 -07:00
Carl Åstholm
9181ecd951 Sema: fix runtime call of inline fn with comptime-known comptime-only ret type 2024-04-07 15:07:55 +02:00
Sean
a2df84d0ff
std.math: rework modf
- Changed `modf_result` to `Modf` to better fit naming conventions
- Reworked `modf` to be far simpler and support all floating point types (as well as vectors) (I have done benchmarks and can confirm that the performance is roughly equivalent to the old implementation)
- Added more descriptive tests for modf
- Deprecated `modf32_result` and `modf64_result` in favor of `Modf(f32)` and `Modf(f64)` respectively
2024-03-29 09:33:57 +00:00
Sean
f32723a237
Update frexp.zig (#19370)
1. Entirely rewrote frexp with generics, reducing the implementation to a single function and enabling parameters of types f80 and f16
2. Expanded upon the tests, making them more descriptive and comprehensive, and automatically generating the test bodies for each floating point type
3. Added a doctest for frexp
2024-03-21 18:08:52 -04:00
tinusgraglin
26e895e3dc math.big.int: fix incorrect bitAnd behavior 2024-03-11 16:52:03 -07:00
Ryan Liptak
726a1149e0 Change many test blocks to doctests/decltests 2024-02-26 15:18:31 -08:00
Ryan Liptak
16b3d1004e Remove redundant test name prefixes now that test names are fully qualified
Follow up to #19079, which made test names fully qualified.

This fixes tests that now-redundant information in their test names. For example here's a fully qualified test name before the changes in this commit:

"priority_queue.test.std.PriorityQueue: shrinkAndFree"

and the same test's name after the changes in this commit:

"priority_queue.test.shrinkAndFree"
2024-02-26 15:18:31 -08:00
Jacob Young
e27db373ec x86_64: implement @clz and @ctz of big integers 2024-02-12 05:25:07 +01:00
Jacob Young
bcbd49b2a6 x86_64: implement shifts of big integers 2024-02-12 05:25:07 +01:00
Jacob Young
9023ff04d0 x86_64: fix register clobber 2024-02-12 05:25:07 +01:00
e4m2
8d56e472c9 Replace std.rand references with std.Random 2024-02-08 15:21:35 +01:00
expikr
b729a3f008
std.math: make hypot infer type from argument (#17910)
using peer type resolution
2024-01-20 01:32:07 -05:00
hdert
314533c28b std/math/pow: Fix #18553, isOddInteger: Return false if float value is greater than 1 << 53 (see comment), add test cases 2024-01-19 22:00:04 -08:00
Andrew Kelley
195eeed2d8 std: remove deprecated API 2024-01-16 04:20:05 -08:00
expikr
ff23efe9fa Update pow.zig 2024-01-14 18:09:26 -08:00
expikr
0c70d9c714 use Peer Type Resolution for standalone complex fn
use peer type resolution

Update complex.zig

Revert "use peer type resolution"

This reverts commit 1bc681ca5b.

Revert "Update pow.zig"

This reverts commit 5487e8d3159f832b5a0bf29a06bd12575182464f.

Update pow.zig

Revert "Update pow.zig"

This reverts commit 521153d1ef.

Update pow.zig
2024-01-14 18:09:17 -08:00
expikr
f9d8176e94
Update atan2.zig (#17840)
Co-authored-by: castholm <carl@astholm.se>
2024-01-14 21:04:30 -05:00
Guillaume Wenzek
c5d359e4cd fix #17142, wrong comptime log_int computation 2024-01-13 18:46:16 -08:00
PauloCampana
fcc0c5ddc7
Add std.math.gamma and lgamma (#18449)
See #7212
2024-01-09 14:53:47 -08:00
Carl Åstholm
4c1da0912a Fix compile errors from the expectEqual change 2024-01-03 21:20:48 +01:00
John Benediktsson
54f4abae2f
Deprecate math.doNotOptimizeAway, use mem.doNotOptimizeAway (#18011) 2023-11-23 15:06:32 -05:00
mlugg
51595d6b75
lib: correct unnecessary uses of 'var' 2023-11-19 09:55:07 +00:00
Jacob Young
0c6cb8d8c8 x86_64: actually track state during @divFloor of i128
Closes #17998
2023-11-14 22:50:05 -05:00
Jakub Konka
ea3f1d27e0 std: disable failing test 2023-11-14 16:51:38 +01:00
Linus Groh
e72049bc61 std.math: Add isPositiveZero() and isNegativeZero() 2023-11-09 00:55:43 -07:00
tison
ee47643b6e
std.math.big: fix sqrt with bits > limb_bits
Signed-off-by: tison <wander4096@gmail.com>
2023-11-08 08:39:08 +02:00
David Rubin
03abac3824 fix sqrt(0) 2023-11-07 14:37:43 +02:00
Jacob Young
509be7cf1f x86_64: fix std test failures 2023-11-03 23:18:21 -04:00
Andrew Kelley
3fc6fc6812 std.builtin.Endian: make the tags lower case
Let's take this breaking change opportunity to fix the style of this
enum.
2023-10-31 21:37:35 -04:00
Jacob Young
f6f2708d82 x86_64: fix compiler rt test failures 2023-10-29 07:20:36 -04:00
Jacob Young
b0cf620fe3 x86_64: fix cond_br 2023-10-27 03:33:49 -04:00
Jacob Young
98cd378208 x86_64: fix behavior of getValue
Old behavior renamed to `getValueIfFree`.
2023-10-26 21:45:58 -04:00
Jacob Young
5e83441096 x86_64: implement @divFloor and @mod for i128 2023-10-26 21:45:57 -04:00
Jacob Young
8f69e977f1 x86_64: implement 128-bit builtins
* `@clz`
 * `@ctz`
 * `@popCount`
 * `@byteSwap`
 * `@bitReverse`
 * various encodings used by std
2023-10-23 22:42:18 -04:00
Jacob Young
fe93332ba2 x86_64: implement enough to pass unicode tests
* implement vector comparison
 * implement reduce for bool vectors
 * fix `@memcpy` bug
 * enable passing std tests
2023-10-23 22:42:18 -04:00
Jacob Young
27fe945a00 Revert "Revert "Merge pull request #17637 from jacobly0/x86_64-test-std""
This reverts commit 6f0198cadb.
2023-10-22 15:46:43 -04:00
Andrew Kelley
6f0198cadb Revert "Merge pull request #17637 from jacobly0/x86_64-test-std"
This reverts commit 0c99ba1eab, reversing
changes made to 5f92b070bf.

This caused a CI failure when it landed in master branch due to a
128-bit `@byteSwap` in std.mem.
2023-10-22 12:16:35 -07:00
Jacob Young
0c99ba1eab
Merge pull request #17637 from jacobly0/x86_64-test-std
x86_64: start to enable `test-std` and `test-compiler-rt` testing
2023-10-22 08:06:47 -04:00
JustinWayland
c45af2af61
Fix simple doc mistakes. (#17624)
* Add missing period in Stack's description

This looks fine in the source, but looks bad when seen on the documentation website.

* Correct documentation for attachSegfaultHandler()

The description for attachSegfaultHandler() looks pretty bad without indicating that the stuff at the end is code

* Added missing 'the's in Queue.put's documentation

* Fixed several errors in Stack's documentation

`push()` and `pop()` were not styled as code

There was no period after `pop()`, which looks bad on the documentation.

* Fix multiple problems in base64.zig

Both "invalid"s in Base64.decoder were not capitalized.

Missing period in documentation of Base64DecoderWithIgnore.calcSizeUpperBound.

* Fix capitalization typos in bit_set.zig

In DynamicBitSetUnmanaged.deinit's and DynamicBitSet.deinit's documentation, "deinitializes" was uncapitalized.

* Fix typos in fifo.zig's documentation

Added a previously missing period to the end of the first line of LinearFifo.writableSlice's documentation.
Added missing periods to both lines of LinearFifo.pump's documentation.

* Fix typos in fmt.bufPrint's documentation

The starts of both lines were not capitalized.

* Fix minor documentation problems in fs/file.zig

Missing periods in documentation for Permissions.setReadOnly, PermissionsWindows.setReadOnly, MetadataUnix.created, MetadataLinux.created, and MetadataWindows.created.

* Fix a glaring typo in enums.zig

* Correct errors in fs.zig

* Fixed documentation problems in hash_map.zig

The added empty line in verify_context's documentation is needed, otherwise autodoc for some reason assumes that the list hasn't been terminated and continues reading off the rest of the documentation as if it were part of the second list item.

* Added lines between consecutive URLs in http.zig

Makes the documentation conform closer to what was intended.

* Fix wrongfully ended sentence in Uri.zig

* Handle wrongly entered comma in valgrind.zig.

* Add missing periods in wasm.zig's documentation

* Fix odd spacing in event/loop.zig

* Add missing period in http/Headers.zig

* Added missing period in io/limited_reader.zig

This isn't in the documentation due to what I guess is a limitation of autodoc, but it's clearly supposed to be. If it was, it would look pretty bad.

* Correct documentation in math/big/int.zig

* Correct formatting in math/big/rational.zig

* Create an actual link to ZIGNOR's paper.

* Fixed grammatical issues in sort/block.zig

This will not show up in the documentation currently.

* Fix typo in hash_map.zig
2023-10-21 21:24:55 +00:00
Jacob Young
32e85d44eb x86_64: disable failing tests, enable test-std testing 2023-10-21 10:55:41 -04:00
Jacob Young
2e6e39a700 x86_64: fix bugs and disable erroring tests 2023-10-21 10:55:41 -04:00
Jacob Young
c880644d92 x86_64: disable difficult std tests and hack around more zero-bit types 2023-10-21 10:55:41 -04:00
castholm
ad6f8e3a59
std.math: add nextAfter (#16894)
`nextAfter()` returns the next representable value after `x` in the direction of `y` and is a standard math library function ([C++](https://en.cppreference.com/w/cpp/numeric/math/nextafter), [Java](https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#nextAfter-double-double-)). It is primarily useful for bitwise incrementing/decrementing floats.

This implementation supports runtime integers, runtime floats and `comptime_int`. `comptime_float` is not supported because NaNs/infinities are intentionally difficult to obtain and because I'm not sure if the fact that it's backed by `f128` is supposed to be an implementation detail. Either way, the user could just call the function with the floating-point type whose behavior they want at comptime and then cast the result to `comptime_float`.

The float implementation was ported from mingw-w64 with some slight changes made possible because the Zig standard library doesn't care about raising FP exceptions.

The number of test cases may seem excessive but they should cover every normal and edge case for every float type and are especially important for verifying that `f80` works.
2023-10-06 14:44:47 -04:00
Philipp Lühmann
ed19ebc360
std.math.big.int.Const.order 0 == -0 (#17299) 2023-09-29 18:09:47 +13:00
antlilja
bcf4a13913 Remove @fabs, fabs and absCast/Int from std lib
Replaces occurences of @fabs absCast and absInt with new @abs builtin.
Also removes the std.math.fabs alias from math.zig.
2023-09-27 11:24:28 -07:00
Federico Stra
4f952c7e0e
std.math.log_int: implement integer logarithm without using float math 2023-09-14 19:33:56 +00:00
Lucas Culverhouse
5b7eefce46
std.math.cbrt: fixed -0.0 evaluating to 0.0 2023-09-12 18:39:34 +00:00
Ruben Dimas
402468b210 std.math.asinh: changed unsigned int to hexadecimal 2023-09-12 22:22:07 +12:00
Ruben Dimas
a8a4f1755e std.math.asinh: fixed -0.0 evaluating to 0.0 2023-09-12 22:22:07 +12:00