202 Commits
Author SHA1 Message Date
CMDRZero 64e4f9db8f Implement partially ordered operator precedence 2026-10-22 12:21:43 +02:00
Jacob Young 3b8913a321 llvm: enable passing tests
Closes #10875
Closes #12396
Closes #20680
Closes #25734
Closes #30854
Closes #35519
2026-07-27 14:44:41 -04:00
Jacob Young 865f329e4f cbe: update for compiler_rt abi changes
* `tools/generate_c_size_and_align_checks.zig`: superceded by any cbe
   output artifact
 * `cTypePreferredAlignment`: no uses, if brought back, cbe should be
   updated to verify `__alignof`

Closes #19991
Closes #20881
Closes #35523
2026-07-27 14:35:12 -04:00
Jacob Young a242b0be88 compiler_rt: change float abi so it can become compatible with cbe 2026-07-27 14:35:12 -04:00
Justus Klausecker 69a26976ed zig fmt
Converts usages of `@intFromEnum` and `@enumFromInt` to instead use the
new `@backingInt` and `@fromBackingInt` builtins.
2026-07-17 23:30:26 +02:00
Pavel Verigo efcaf6a72d lib: use @divCeil 2026-07-06 20:49:09 +02:00
Nguyen Gia Huy 1d1193aa7b std.math: Mark signExtend as pub
Introduced in https://codeberg.org/ziglang/zig/commit/b636906fb640a12107cd21637c2af67b8e9d6ebd
2026-06-30 02:24:16 +00:00
whatisaphone b636906fb6 std.math: Add signExtend 2026-06-26 23:30:13 +02:00
Andrew Kelley 9ad29fbc6c disable failing tests revealed by this branch
See #35517
See #35518
See #35519
See #35520
See #35521
See #35522
See #35523
See #35537
2026-05-29 15:32:27 -07:00
Krzysztof Wolicki 9e80795623 all: update to use new std.lang.Type definitions 2026-05-27 10:03:51 +01:00
Linus Groh 991f56fd6b std.meta: Remove Int in favor of @Int 2026-05-03 21:42:06 +01:00
Matthew Lugg 213c4fc25f lib,test: remove uses of i0
In preparation for its removal, as accepted in
https://github.com/ziglang/zig/issues/1593.
2026-04-30 08:57:51 +01:00
mihael 764760df62 libzigc/math: Implement rintl, lrintl (#31791)
It's a fairly straightforward port of `musl`'s `rintl`, like `rint` and `rintf` were. `libc-test` tests for `rintl` are uncommented since they're now passing.

I've also covered special cases for `rint` with tests, and broke down the current `rint` and `modf` test declarations into multiple -- so each libc function get its own test declaration at the very least.

Contributes to #30978

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31791
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
2026-04-27 16:48:55 +02:00
Hila Friedman bfd2cc5a3f even tighter return type for std.math.sign (#31485)
The code in #31475 does not return the "smallest integer type that fits possible values" for very small integer types, namely `u0`, `i0`, and `i1` - which all end up with a return type one bit too long. Fixed in this commit.

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/31485
Reviewed-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: Hila Friedman <red.black.liquorice@gmail.com>
Co-committed-by: Hila Friedman <red.black.liquorice@gmail.com>
2026-03-17 02:10:27 +01:00
Jay Petacat 01cc1a5867 std.math.sign: Return smallest integer type that fits possible values
This may be a breaking change for callers that depend on the return type
size being identical to the input. For example, `sign(i32) * i8 + i8`
could now overflow. Callers can add an explicit type annotation to avoid
that problem.
2026-03-12 21:05:22 +01:00
Ali CheraghiandMatthew Lugg dec1163fbb all: replace all @Type usages
Co-authored-by: Matthew Lugg <mlugg@mlugg.co.uk>
2025-11-22 22:42:38 +00:00
Alex Rønne Petersen af78c55676 std: skip some failing tests on hexagon 2025-08-30 06:36:41 +02:00
Fri3dNstuff f758b97bfd std.math: Add splat for vectors of u0s in rotl/rotr (#24822) 2025-08-15 23:45:33 +02:00
mlugg 64bf8bb146 std: stop relying on precision-losing coercions 2025-07-31 10:57:04 +01:00
Jacob Young 5060ab99c9 aarch64: add new from scratch self-hosted backend 2025-07-22 19:43:47 -07:00
Jacob Young 6b41beb370 big.int: implement float conversions
These conversion routines accept a `round` argument to control how the
result is rounded and return whether the result is exact. Most callers
wanted this functionality and had hacks around it being missing.

Also delete `std.math.big.rational` because it was only being used for
float conversion, and using rationals for that is a lot more complex
than necessary. It also required an allocator, whereas the new integer
routines only need to be passed enough memory to store the result.
2025-06-15 14:15:18 -04:00
Alex Rønne Petersen 9d534790eb std.Target: Introduce Cpu convenience functions for feature tests.
Before:

* std.Target.arm.featureSetHas(target.cpu.features, .has_v7)
* std.Target.x86.featureSetHasAny(target.cpu.features, .{ .sse, .avx, .cmov })
* std.Target.wasm.featureSetHasAll(target.cpu.features, .{ .atomics, .bulk_memory })

After:

* target.cpu.has(.arm, .has_v7)
* target.cpu.hasAny(.x86, &.{ .sse, .avx, .cmov })
* target.cpu.hasAll(.wasm, &.{ .atomics, .bulk_memory })
2025-06-05 06:12:00 +02:00
Jacob Young 58d2bd601e x86_64: rewrite scalar <<|
Closes #23035
2025-05-17 18:00:17 -04:00
Andrew Kelley f32a5d349d std: eradicate u29 and embrace std.mem.Alignment 2025-04-13 02:20:32 -04:00
oittaa c1db72cdbc std.math: Add least common multiple (lcm) 2025-03-24 16:07:40 +01:00
Jacob Young 348d1773ba std: remove special cases for stage2_x86_64 that are no longer needed 2025-02-12 09:48:17 -05:00
Jeremy Hertel 227fb4875f std.math: rename make_f80 to F80.toFloat and break_f80 to F80.fromFloat 2024-09-02 00:10:22 +03:00
mlugg 0fe3fd01dd std: update std.builtin.Type fields to follow naming conventions
The compiler actually doesn't need any functional changes for this: Sema
does reification based on the tag indices of `std.builtin.Type` already!
So, no zig1.wasm update is necessary.

This change is necessary to disallow name clashes between fields and
decls on a type, which is a prerequisite of #9938.
2024-08-28 08:39:59 +01:00
mlugg 018262d537 std: update eval branch quotas after bdbc485
Also, update `std.math.Log2Int[Ceil]` to more efficient implementations
that don't use up so much damn quota!
2024-08-21 01:30:46 +01:00
T eb7f318ea8 langref: clarify functionality of the round builtin (#19503)
A test has also been added to demonstrate the expected behavior.

* std.math: update round doc comment to match the builtin
2024-08-14 10:29:45 -07:00
Julian Vesper 3344ed8b8f aarch64: reenable tests that are no longer regressed
Closes #12012
2024-07-25 20:23:23 +03:00
koenditor 64ef45eb05 Support Vectors in std.math.clamp 2024-06-01 13:28:16 +03:00
Manlio Perillo e54fcdb5b2 std/math: import "math/float.zig" only once
math.zig imported the "math/float.zig" file multiple time, making the
code unnecessarily more verbose.
2024-05-30 19:57:24 +03:00
expikr 103b885fc6 math.hypot: fix incorrect over/underflow behavior (#19472) 2024-05-30 09:58:05 +00:00
Ryan Liptak a52f12afc9 Delete compile errors for deprecated decls 2024-05-03 13:27:30 -07:00
Jacob Young 425e38b6e0 WindowsSdk: fix for new x86_64-windows CI 2024-04-14 21:26:08 -04: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
Andrew Kelley 12191c8a22 std: promote tests to doctests
Now these show up as "example usage" in generated documentation.
2024-03-21 14:11:46 -07:00
expikr 67a40c679d make math.degreesToRadians and math.radiansToDegrees infer type from argument 2024-03-15 16:31:02 +02:00
paoda a4508ad716 fix(math): eval isPowerOfTwo at comptime in rotl/rotr 2024-03-15 16:19:48 +02:00
pancelor 7a858257f2 remove math.lerp bounds for t
I think of lerp() as a way to change coordinate systems, essentially
remapping the input numberline onto a shifted+rescaled numberline. In
my mind the full numberline is remapped, not just the 0-1 segment.

An example of how this is useful: in a game, you can write:
`myPos = lerp(pos0, pos1, easeOutBack(u))`
for some `u` that changes from 0 to 1 over time.
(see https://easings.net/#easeOutBack)
This will animate `myPos` between `pos0` and `pos1`, overshooting the
goal position `pos1` in a nicely-animated way.
`easeOutBack(float)->float` is a pure function that overshoots 1,
and by combining it with `lerp()` we can remap coordinates in other
coordinate systems, making them overshoot in the same way.

However, this overshooting is only possible because `easeOutBack(t)`
sometimes exceeds the range 0-1 (e.g. `easeOutBack(0.5)` is 1.0877),
which is not allowed by the current `math.lerp` implementation.

This commit removes the asserts that prevented this use-case. Now, any
value can be inputted for t. For example, `lerp(10,20, 2.0)` will now
return 30, instead of throwing an assert error.
2024-03-13 18:35:07 -07: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
expikr 1a7a711964 std.math: add wrap function (#18154) 2024-01-14 20:45:39 -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
Eric Eastwood 2115d7d1be Add approxEqAbs support for comptime_float 2024-01-07 22:23:06 -08:00
Jacob Young 98b633ff17 Reapply "Merge pull request #17824 from kcbanner/fixup_msvc_fmax"
This reverts commit 2b58978360.
2024-01-03 02:41:21 -05:00
Andrew Kelley 2b58978360 Revert "Merge pull request #17824 from kcbanner/fixup_msvc_fmax"
This reverts commit 7161ed79c4, reversing
changes made to 3f2a65594e.

Unfortunately, this sat in the PR queue too long and the merge broke the
zig1.wasm bootstrap process.
2024-01-01 17:49:57 -07:00
Andrew Kelley 7161ed79c4 Merge pull request #17824 from kcbanner/fixup_msvc_fmax
cbe: add a system for avoiding collisions with C compiler intrinsics
2024-01-01 15:36:16 -08:00
John Benediktsson 54f4abae2f Deprecate math.doNotOptimizeAway, use mem.doNotOptimizeAway (#18011) 2023-11-23 15:06:32 -05:00