aboutsummaryrefslogtreecommitdiff
path: root/lib/std/math.zig
AgeCommit message (Collapse)Author
2023-08-02Remove math.ln in favor of `@log`Adam Goertz
2023-07-12Remove len parameter from splat in standard libantlilja
2023-07-09Change math.Order order (#16356)Niles Salter
This speeds up algorithms like binary search
2023-06-24all: migrate code to new cast builtin syntaxmlugg
Most of this migration was performed automatically with `zig fmt`. There were a few exceptions which I had to manually fix: * `@alignCast` and `@addrSpaceCast` cannot be automatically rewritten * `@truncate`'s fixup is incorrect for vectors * Test cases are not formatted, and their error locations change
2023-06-19all: zig fmt and rename "@XToY" to "@YFromX"Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-18std.math.isPowerOfTwo: add tests and doc comment and improve assertr00ster91
The assert is changed from `int != 0` to `int > 0` because negative integers always return `false`. Python's `math.log2` does the same and errors for 0 or negative integers.
2023-06-16migration: std.math.{min, min3, max, max3} -> `@min` & `@max`r00ster91
2023-06-13all: replace `comptime try` with `try comptime`Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13std.math: hard deprecate obsolete constants (soft deprecated in 0.10)Eric Joldasov
Followup to 5b8ac9821dd25c3e5282130b4d93d6c5b7debb08. Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-05-29std.io.Writer: add support for non-power-of-two int sizesCortex
2023-05-24make `@boolToInt` always return a u1tison
Signed-off-by: tison <wander4096@gmail.com>
2023-04-23Improvements to docs and textzooster
* docs(std.math): elaborate on difference between absCast and absInt * docs(std.rand.Random.weightedIndex): elaborate on likelihood I think this makes it easier to understand. * langref: add small reminder * docs(std.fs.path.extension): brevity * docs(std.bit_set.StaticBitSet): mention the specific types * std.debug.TTY: explain what purpose this struct serves This should also make it clearer that this struct is not supposed to provide unrelated terminal manipulation functionality such as setting the cursor position or something because terminals are complicated and we should keep this struct simple and focused on debugging. * langref(package listing): brevity * langref: explain what exactly `threadlocal` causes to happen * std.array_list: link between swapRemove and orderedRemove Maybe this can serve as a TLDR and make it easier to decide. * PrefetchOptions.locality: clarify docs that this is a range This confused me previously and I thought I can only use either 0 or 3. * fix typos and more * std.builtin.CallingConvention: document some CCs * langref: explain possibly cryptic names I think it helps knowing what exactly these acronyms (@clz and @ctz) and abbreviations (@popCount) mean. * variadic function error: add missing preposition * std.fmt.format docs: nicely hyphenate * help menu: say what to optimize for I think this is slightly more specific than just calling it "optimizations". These are speed optimizations. I used the word "performance" here.
2023-04-20std.math: add lerp (#13002)zooster
2023-04-12Zir: implement explicit block_comptime instructionmlugg
Resolves: #7056
2023-03-22std.math: port int log10 from RustAdrian Delgado
2023-01-03math: implement absInt for integer vectorsJordan Lewis
This commit adds support to absInt for integer vectors.
2022-12-27Revert "aarch64: reenable tests that are no longer regressed"Andrew Kelley
This reverts commit 3370d58956ecc744a004dff47b0437473f0ef7da. This commit was done with an LLVM build that did not have assertions enabled. There are LLVM assertions being triggered due to this commit. Reopens #10627 Reopens #12013 Reopens #12027
2022-12-27update uses of overflow arithmetic builtinsVeikka Tuominen
2022-12-15std: add CompareOperator.reverseStevie Hryciw
2022-12-10aarch64: reenable tests that are no longer regressedr00ster91
Closes #12013 Closes #10627 Closes #12027
2022-12-09Improve and remove duplicate doNotOptimizeAway() implementations (#13790)Frank Denis
* Improve and remove duplicate doNotOptimizeAway() implementations We currently have two doNotOptimizeAway() implementations, one in std.math and the other one in std.mem. Maybe we should deprecate one. In the meantime, the std.math one now just calls the std.mem one. In a comptime environment, just ignore the value. Previously, std.mem.doNotOptimizeAway() did not work at comptime. If the value fits in a CPU register, just tell the compiler we need that value to be computed, without clobbering anything else. Only clobber all possibly escaped memory on pointers or large arrays. Add tests by the way since we didn't had any (we had, but only indirect ones).
2022-12-06remove most conditional compilation based on stage1Andrew Kelley
There are still a few occurrences of "stage1" in the standard library and self-hosted compiler source, however, these instances need a bit more careful inspection to ensure no breakage.
2022-11-12Implements std.math.sign for float vectors.IntegratedQuantum
2022-10-15Merge pull request #12918 from jacobly0/math-cast-comptime-intAndrew Kelley
std.math: fix behavior relating to comptime_int arguments
2022-10-12Merge pull request #13081 from r00ster91/docsAndrew Kelley
fix(text): hyphenation and other fixes
2022-10-11std.math: add support to cast for a comptime_int argumentJacob Young
This allows converting a comptime_int to an optional integer type, which either behaves the same as an implicit cast or produces null if the argument is outside the range of the destination type.
2022-10-11std/math.zig: use previous rotate code with non-power-of-two integersRekai Nyangadzayi Musuka
2022-10-05fix(text): hyphenation and other fixesr00ster91
2022-10-01std.math: allow comptime_float for radiansToDegrees and degreesToRadianszooster
And some other minor things.
2022-09-29std.math: add "Greatest common divisor" (gcd)Chris Boesch
2022-09-16std: remove deprecated API for the upcoming releaseAndrew Kelley
See #3811
2022-09-12remove pointless discardsAndrew Kelley
2022-08-24Merge pull request #12574 from Vexu/remove-bit-op-type-paramAndrew Kelley
stage2+stage1: remove type parameter from bit builtins
2022-08-22stage2+stage1: remove type parameter from bit builtinsVeikka Tuominen
Closes #12529 Closes #12511 Closes #6835
2022-08-22Sema: fix parameter of type 'T' must be comptime errorVeikka Tuominen
Closes #12519 Closes #12505
2022-07-11std.math: add `degreesToRadians` and `radiansToDegrees`frmdstryr
2022-07-09two more regressed test cases; same cause as last two commitsAndrew Kelley
2022-07-09disable regressed math.sign test caseAndrew Kelley
see #12012
2022-07-06std: disable aarch64 tests that regressed from LLVM 14Andrew Kelley
See #12012
2022-05-27math: make `cast` return optional instead of an errorAli Chraghi
2022-05-19Add aliases to math builtins back into std.math (#11666)frmdstryr
2022-05-12add std.math.signTravis Staloch
2022-04-27compiler-rt: math functions reorgAndrew Kelley
* unify the logic for exporting math functions from compiler-rt, with the appropriate suffixes and prefixes. - add all missing f128 and f80 exports. Functions with missing implementations call other functions and have TODO comments. - also add f16 functions * move math functions from freestanding libc to compiler-rt (#7265) * enable all the f128 and f80 code in the stage2 compiler and behavior tests (#11161). * update std lib to use builtins rather than `std.math`.
2022-04-27std: replace usage of std.meta.bitCount() with @bitSizeOf()Isaac Freund
2022-04-15std/math.zig: resolve missed optimization in rotatesRekai Musuka
2022-04-12Add `floatFractionalBits` to replace `floatMantissaDigits`Cody Tapscott
2022-04-07use math/float.zig everywhereviri
2022-04-07std.math: generalise `inf`, even simpler `isFinite`viri
2022-04-06derive float constants in a generic way (#10133)viri
2022-04-05zig fmt: remove trailing whitespace on doc commentsDamien Firmenich
Fixes #11353 The renderer treats comments and doc comments differently since doc comments are parsed into the Ast. This commit adds a check after getting the text for the doc comment and trims whitespace at the end before rendering. The `a = 0,` in the test is here to avoid a ParseError while parsing the test.