Skip to content

std.math.isnan output is different from comptime_float vs f32 #21198

Open
@cowboy8625

Description

@cowboy8625

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

const std = @import("std");

pub fn main() !void {
    const foo = 0.0;
    std.debug.print("foo / foo std.math.isnan({d:.2}) = {any}\n", .{ foo, std.math.isNan(foo / foo) });
    const bar: f32 = 0.0;
    std.debug.print("bar / bar std.math.isnan({d:.2}) = {any}\n", .{ bar, std.math.isNan(bar / bar) });
}

OUTPUT:

foo / foo std.math.isnan(0.00) = false
bar / bar std.math.isnan(0.00) = true

Expected Behavior

I would expect comptime_float and f32 would result in the same output of true.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions