aboutsummaryrefslogtreecommitdiff
path: root/lib/std/math.zig
AgeCommit message (Collapse)Author
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.
2022-03-30replace other uses of `std.meta.Vector` with `@Vector` (#11346)Meghan
2022-03-12std.math.lossyCast: fix integer overflowominitay
Fixes integer overflow caused by cast from maxInt(u32) as an f32 to u32.
2022-03-11std.math: remove redundant namespace in test namesAndrew Kelley
related: #7923
2022-02-23stage2: misc fixes in SemaVeikka Tuominen
2022-02-13Simplify implementation of floorPowerOfTwo in std.mathCody Tapscott
2022-02-12make f80 less hacky; lower as u80 on non-x86Andrew Kelley
Get rid of `std.math.F80Repr`. Instead of trying to match the memory layout of f80, we treat it as a value, same as the other floating point types. The functions `make_f80` and `break_f80` are introduced to compose an f80 value out of its parts, and the inverse operation. stage2 LLVM backend: fix pointer to zero length array tripping LLVM assertion. It now checks for when the element type is a zero-bit type and lowers such thing the same way that pointers to other zero-bit types are lowered. Both stage1 and stage2 LLVM backends are adjusted so that f80 is lowered as x86_fp80 on x86_64 and i386 architectures, and identical to a u80 on others. LLVM constants are lowered in a less hacky way now that #10860 is fixed, by using the expression `(exp << 64) | fraction` using llvm constants. Sema is improved to handle c_longdouble by recursively handling it correctly for whatever the float bit width is. In both stage1 and stage2.
2022-02-12stage1: fix f80 size and alignment on x86 and armAndrew Kelley
* F80Repr extern struct needs no explicit padding; let's match the target padding. * stage2: fix lowering of f80 constants. * stage1: decide ABI size and alignment of f80 based on alignment of u64. x86 has alignof u64 equal to 4 but arm has it as 8. * stage2: fix Value.floatReadFromMemory to use F80Repr
2022-02-04stage1: make f80 always size 16, align 16Veikka Tuominen
2022-02-04compiler-rt: add extend functions for f80Veikka Tuominen
2022-01-28std: add f80 bitsVeikka Tuominen
2021-11-30std lib API deprecations for the upcoming 0.9.0 releaseAndrew Kelley
See #3811
2021-11-23std/math: add ldexp and make scalbn an aliasMarc Tiehuis
We assume we are compiled on a base-2 radix floating point system. This is a reasonable assumption. musl libc as an example also assumes this. We implement scalbn as an alias for ldexp, since ldexp is defined as 2 regardless of the float radix. This is opposite to musl which defines scalbn in terms of ldexp. Closes #9799.
2021-10-05add support for f128 `@mulAdd`Andrew Kelley
std: add f128 implementations of fma, frexp, and ilogb. Expose `fmal` in zig's freestanding libc. This makes `@mulAdd` work correctly for f128. Fixes a CI regression from yesterday, where I added a usage of f128 `@mulAdd` into the self-hosted compiler.
2021-10-04add phi constantalichraghi
2021-10-02Document some functions in std.math.Nathan Michaels
2021-09-14add functions to decode an epoch timestamp (#9040)Jonathan Marler
* add functions to decode an epoch timestamp The code added here is alternative to the libc gmtime function. This function takes a unix epoch timestamp and decodes it into things like the year/day/time/etc. I looked at various libc implementations to see how it was implemented and this appears to be correct. I reorganized it so that applications can choose which data they need rather than calcualting it all in a single function. The data structures layout the order of operations required to decode various things like the year/month or time of day. * set Month.jan to 1 instead of 0 to avoid +1 in conversion to numeric * add another test * remove unnecessary comptimeMod
2021-08-24remove redundant license headers from zig standard libraryAndrew Kelley
We already have a LICENSE file that covers the Zig Standard Library. We no longer need to remind everyone that the license is MIT in every single file. Previously this was introduced to clarify the situation for a fork of Zig that made Zig's LICENSE file harder to find, and replaced it with their own license that required annual payments to their company. However that fork now appears to be dead. So there is no need to reinforce the copyright notice in every single file.
2021-08-23Trivial typo "for for" --> "for" (also a few nearby run-on sentence). (#9610)William Stein
2021-06-10zig fmtAndrew Kelley
2021-06-03Breaking hash map changes for 0.8.0Martin Wickham
- hash/eql functions moved into a Context object - *Context functions pass an explicit context - *Adapted functions pass specialized keys and contexts - new getPtr() function returns a pointer to value - remove functions renamed to fetchRemove - new remove functions return bool - removeAssertDiscard deleted, use assert(remove(...)) instead - Keys and values are stored in separate arrays - Entry is now {*K, *V}, the new KV is {K, V} - BufSet/BufMap functions renamed to match other set/map types - fixed iterating-while-modifying bug in src/link/C.zig
2021-05-20Run `zig fmt` on src/ and lib/std/Isaac Freund
This replaces callconv(.Inline) with the more idiomatic inline keyword.
2021-05-08Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * doc/langref.html.in * lib/std/enums.zig * lib/std/fmt.zig * lib/std/hash/auto_hash.zig * lib/std/math.zig * lib/std/mem.zig * lib/std/meta.zig * test/behavior/alignof.zig * test/behavior/bitcast.zig * test/behavior/bugs/1421.zig * test/behavior/cast.zig * test/behavior/ptrcast.zig * test/behavior/type_info.zig * test/behavior/vector.zig Master branch added `try` to a bunch of testing function calls, and some lines also had changed how to refer to the native architecture and other `@import("builtin")` stuff.
2021-05-08std: update usage of std.testingVeikka Tuominen
2021-04-24Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
In particular I wanted the change that makes `suspend;` illegal in the parser.
2021-04-23std: Remove unneeded workaroundLemonBoy
Now that -% works on unsigned integers at comptime this (clever) hack is not not needed anymore.
2021-04-22std: remove `comptime const`Andrew Kelley
2021-03-01zig fmt the std libAndrew Kelley
2021-03-01Add some bit set variantsMartin Wickham
2021-01-25Merge pull request #7846 from LemonBoy/filtertestAndrew Kelley
stage1: don't filter test blocks with empty label
2021-01-22std: Update `test ""` to `test` where it makes senseLemonBoy
2021-01-19stage2: ELF: avoid multiplication for ideal capacityAndrew Kelley
ideal capacity is now determined by e.g. x += x / f rather than x = x * b / a This turns a multiplication into an addition, making it less likely to overflow the integer. This commit also introduces padToIdeal() which does saturating arithmetic so that no overflow is possible when calculating ideal capacity. closes #7830