Too restrictive return type in std.math.min #3035
Labels
bug
Observed behavior contradicts documented or intended behavior
standard library
This issue involves writing Zig code for the standard library.
Milestone
Since 2cd5e55, the return type of std.math.min is made more restrictive in some situations. However, it seems to me that it is made too restrictive: if
A
andB
are both signed ints (for instance,i16
andi32
), then the most restrictive type able to contain the result is the widest of the two. Indeed, in the above case, the minimum might be as little as -2^31, which does not fit in ani16
.Likewise, floats are always signed and the return type should be the widest of the two.
I am not sure about comptime ints and floats: should the return type depend on the comptime value?
The text was updated successfully, but these errors were encountered: