Zig Version
0.16.0
Steps to Reproduce and Observed Behavior
I stumbled on this by accident, but the title describes the problem quite accurately: acosh should return nan for negative numbers, but returns finite values for some large negative values.
Steps to reproduce
Input:
const std: type = @import("std");
pub fn main() void {
const x: f64 = -1.9e4;
const result: f64 = std.math.acosh(x);
std.debug.print("x: {e}, acosh(x): {e}, isNan: {}\n", .{ x, result, std.math.isNan(result) });
}
Output:
x: -1.9e4, acosh(x): -7.288321402140781e0, isNan: false
This seems to start returning finite values for inputs smaller than -1e4. It seems to work correctly for certain values (e.g. 4e-4, 1.5e-4, 2e-4).
Reproducible with the following build modes:
- Debug Mode / Default
zig run and zig build run.
- ReleaseFast, ReleaseSafe.
Observed Behaviour
std.math.acosh(-1.9e4) returns -7.288321402140781e0
std.math.acosh(-2e4) returns -nan
Environment Information
- OS: NixOS Yarara
- Zig version: 0.16.0
- target: x86_64-linux.6.19.8...6.19.8-gnu.2.42 (Intel Alderlake)
Expected Behavior
Expected Behaviour
std.math.acosh(-1.9e4) should return nan
std.math.acosh(-2e4) should return nan
### Zig Version
0.16.0
### Steps to Reproduce and Observed Behavior
I stumbled on this by accident, but the title describes the problem quite accurately: acosh should return `nan` for negative numbers, but returns finite values for some large negative values.
### Steps to reproduce
Input:
```
const std: type = @import("std");
pub fn main() void {
const x: f64 = -1.9e4;
const result: f64 = std.math.acosh(x);
std.debug.print("x: {e}, acosh(x): {e}, isNan: {}\n", .{ x, result, std.math.isNan(result) });
}
```
Output:
```x: -1.9e4, acosh(x): -7.288321402140781e0, isNan: false```
This seems to start returning finite values for inputs smaller than `-1e4`. It seems to work correctly for certain values (e.g. `4e-4, 1.5e-4`, `2e-4`).
Reproducible with the following build modes:
- Debug Mode / Default `zig run` and `zig build run`.
- ReleaseFast, ReleaseSafe.
### Observed Behaviour
- `std.math.acosh(-1.9e4)` returns `-7.288321402140781e0`
- `std.math.acosh(-2e4)` returns `-nan`
### Environment Information
- OS: NixOS Yarara
- Zig version: 0.16.0
- target: x86_64-linux.6.19.8...6.19.8-gnu.2.42 (Intel Alderlake)
### Expected Behavior
### Expected Behaviour
- `std.math.acosh(-1.9e4)` should return `nan`
- `std.math.acosh(-2e4)` should return `nan`