0
Fork 0
mirror of https://codeberg.org/ziglang/zig synced 2026-11-18 07:05:05 +00:00
zig/lib/std
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.
History 2023-10-06 14:44:47 -04:00
..
atomic write function types consistently with a space before fn keyword 2023-09-19 15:15:05 +03:00
Build comp: add support for -fdata-sections 2023-10-04 11:21:56 -07:00
c Merge pull request #17341 from rzezeski/illumos-updates 2023-10-03 11:04:41 -07:00
compress all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
crypto Add illumos OS tag 2023-10-02 15:31:49 -06:00
dwarf Add illumos OS tag 2023-10-02 15:31:49 -06:00
event all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
fmt re-enable test "fmt.parseFloat nan and inf" after llvm fix 2023-07-25 11:03:11 -07:00
fs Add illumos OS tag 2023-10-02 15:31:49 -06:00
hash std/hash: perform iterative + smhasher tests at comptime 2023-09-02 16:58:03 +12:00
heap GeneralPurposeAllocator.searchBucket: check current bucket before searching the list 2023-10-04 02:55:54 -07:00
http std.http: introduce options to http client to allow for raw uris 2023-09-28 14:16:39 +03:00
io std: add type-erased reader; base GenericReader on it 2023-10-03 14:55:17 -07:00
json std.json: add fmt function (#17055) 2023-09-13 18:24:59 -04:00
math std.math: add nextAfter (#16894) 2023-10-06 14:44:47 -04:00
mem mem: explicit dupe and dupeZ error on Allocator 2023-09-07 21:56:57 +03:00
meta all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
net std.net: Fix IPv6 address parsing for single digit 2023-09-06 11:14:24 +03:00
os x86_64: implement C abi for 128-bit integers 2023-10-04 14:42:35 -04:00
rand Remove @fabs, fabs and absCast/Int from std lib 2023-09-27 11:24:28 -07:00
sort improve documentation of std.sort.*Context functions (#16145) 2023-06-27 00:51:06 -07:00
target nvptx: omit sm_90a from the CPU target features for now 2023-09-19 09:37:53 -07:00
testing std: enable FailingAllocator to fail on resize 2023-09-06 19:06:32 +03:00
Thread Fix counting in SingleThreadedRwLock's tryLockShared (#16560) 2023-07-26 08:19:52 -05:00
time all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
tz Support legacy TZ format, expose header struct to a potential writer 2022-01-01 12:47:08 +00:00
unicode all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
valgrind valgrind.memcheck: fix makeMem*() 2023-10-03 02:51:01 -07:00
zig Merge pull request #17341 from rzezeski/illumos-updates 2023-10-03 11:04:41 -07:00
array_hash_map.zig std.MultiArrayList: add test coverage for 0-bit structs 2023-09-24 15:49:56 -07:00
array_list.zig Improve (Unmanaged)ArrayList.insert 2023-09-30 16:17:22 -07:00
ascii.zig migration: std.math.{min, min3, max, max3} -> @min & @max 2023-06-16 13:44:09 -07:00
atomic.zig std: remove names from incorrectly named tests 2023-04-21 23:08:48 -04:00
base64.zig Optimize std.base64.standard.Encoder.encode 2023-08-29 16:00:31 -04:00
bit_set.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
BitStack.zig std.json: Unify stringify and writeStream (#16405) 2023-07-21 19:56:46 -04:00
bounded_array.zig Smaller memory footprint for BoundedArray (#16299) 2023-07-03 13:58:03 -04:00
buf_map.zig doc: fix minor grammar issues 2023-04-22 13:09:15 +03:00
buf_set.zig update codebase to use @memset and @memcpy 2023-04-28 13:24:43 -07:00
Build.zig Support non zig dependencies 2023-09-24 02:47:21 +01:00
builtin.zig std.os.uefi: reorganize namespaces 2023-08-24 22:38:47 -07:00
c.zig Add illumos OS tag 2023-10-02 15:31:49 -06:00
child_process.zig Sema: add @errorCast which works for both error sets and error unions 2023-10-01 17:00:01 +03:00
coff.zig std.coff: Fixed compile error. 2023-09-02 00:18:53 +02:00
compress.zig std.compress.zstd: renamed from std.compress.zstandard 2023-02-22 00:11:20 +11:00
comptime_string_map.zig ComptimeStringMap: Add version that takes an equality function 2023-09-14 11:03:15 -07:00
crypto.zig std.crypto.ff - Alloc-free, constant-time field arithmetic for crypto (#15795) 2023-05-22 16:11:06 +02:00
cstr.zig std.cstr: deprecate namespace 2023-06-25 14:51:03 -07:00
debug.zig Add illumos OS tag 2023-10-02 15:31:49 -06:00
dwarf.zig std: remove some unused imports (#16710) 2023-08-06 15:18:50 -04:00
dynamic_library.zig Add illumos OS tag 2023-10-02 15:31:49 -06:00
elf.zig std: remove some unused imports (#16710) 2023-08-06 15:18:50 -04:00
enums.zig Allow empty enum to be used in EnumSet/EnumMap 2023-09-28 21:48:39 +00:00
event.zig std, compiler-rt: remove test names where applicable 2021-09-01 17:54:06 -07:00
fifo.zig std: remove some unused imports (#16710) 2023-08-06 15:18:50 -04:00
fmt.zig Remove @fabs, fabs and absCast/Int from std lib 2023-09-27 11:24:28 -07:00
fs.zig Merge pull request #17341 from rzezeski/illumos-updates 2023-10-03 11:04:41 -07:00
hash.zig add std.hash.uint32 2023-06-10 20:42:30 -07:00
hash_map.zig std: remove some unused imports (#16710) 2023-08-06 15:18:50 -04:00
heap.zig std: remove some unused imports (#16710) 2023-08-06 15:18:50 -04:00
http.zig std.http: add identity to content encodings (#16493) 2023-09-26 17:16:40 -04:00
Ini.zig add std.Ini for basic .ini file parsing 2023-01-11 15:39:48 -08:00
io.zig std: add type-erased reader; base GenericReader on it 2023-10-03 14:55:17 -07:00
json.zig std.json: add fmt function (#17055) 2023-09-13 18:24:59 -04:00
leb128.zig Use builtin inference over @as where possible 2023-07-24 10:23:51 -07:00
linked_list.zig std: Move TailQueue alias to correct namespace 2023-08-28 17:41:37 -07:00
log.zig all: zig fmt and rename "@XToY" to "@YFromX" 2023-06-19 12:34:42 -07:00
macho.zig std.macho: remove alignment from LoadCommandIterator 2023-10-03 14:55:17 -07:00
math.zig std.math: add nextAfter (#16894) 2023-10-06 14:44:47 -04:00
mem.zig std.mem.zeroes: Zero out entire extern union, including padding 2023-10-01 02:39:05 -07:00
meta.zig Remove @fabs, fabs and absCast/Int from std lib 2023-09-27 11:24:28 -07:00
multi_array_list.zig std.MultiArrayList: add test coverage for 0-bit structs 2023-09-24 15:49:56 -07:00
net.zig std.net: Fix IPv6 address parsing for single digit 2023-09-06 11:14:24 +03:00
once.zig update std lib and compiler sources to new for loop syntax 2023-02-18 19:17:21 -07:00
os.zig linux: add fanotify API 2023-10-04 13:48:22 +03:00
packed_int_array.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
pdb.zig std.pdb: fix incorrect field alignment in ptrCast 2023-06-30 23:23:03 -04:00
priority_dequeue.zig [priority_dequeue] Fix out-of-bounds access 2023-06-22 02:03:53 -07:00
priority_queue.zig [priority_queue] Simplify sifting & fix edge case 2023-07-24 12:58:19 -07:00
process.zig Add illumos OS tag 2023-10-02 15:31:49 -06:00
Progress.zig std.Progress: add optional unit to progress indicator 2023-07-25 13:51:22 +01:00
rand.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
RingBuffer.zig all: zig fmt and rename "@XToY" to "@YFromX" 2023-06-19 12:34:42 -07:00
segmented_list.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
SemanticVersion.zig std: replace builtin.Version with SemanticVersion 2023-06-17 13:17:34 -07:00
simd.zig std: Reactivate skipped tests w.r.t. llvm/llvm-project#55522 2023-09-27 01:37:25 +03:00
sort.zig improve documentation of std.sort.*Context functions (#16145) 2023-06-27 00:51:06 -07:00
start.zig start: workaround for LLVM 17 regression 2023-09-19 09:37:32 -07:00
start_windows_tls.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
std.zig ComptimeStringMap: Add version that takes an equality function 2023-09-14 11:03:15 -07:00
tar.zig zig fetch: enhanced error reporting 2023-10-02 17:02:25 -07:00
target.zig illumos: fix dynamic linker path 2023-10-02 16:37:37 -06:00
testing.zig std.testing: expectEqualDeep() - support self-referential structs 2023-09-23 20:25:57 +00:00
Thread.zig Add illumos OS tag 2023-10-02 15:31:49 -06:00
time.zig implement std.time.sleep for uefi 2023-07-07 11:57:09 -07:00
treap.zig Treap: do not set key to undefined in remove to allow re-use of removed nodes 2023-10-03 01:21:51 -07:00
tz.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
unicode.zig std.json: Fix decoding of UTF-16 surrogate pairs (#16830) 2023-08-15 09:11:59 -04:00
Uri.zig Allow only relative paths. 2023-09-29 00:32:43 -07:00
valgrind.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00
wasm.zig all: zig fmt and rename "@XToY" to "@YFromX" 2023-06-19 12:34:42 -07:00
zig.zig all: migrate code to new cast builtin syntax 2023-06-24 16:56:39 -07:00