Why does `std.math.floatMax(T)` return `T` instead of `comptime_float`?

I noticed a difference in return types:

  • std.math.maxInt(T) returns comptime_int
  • std.math.floatMax(T) returns T

I was wondering what the reasoning for this design is. Is there a specific technical constraint that prevents std.math.floatMax(T) from returning a comptime_float?

Currently, I’m using @as(comptime_float, std.math.floatMax(T)) to get the comptime_float value, which works fine. I’m mostly just curious about the design choice

There is a proposal to change that: std.math.{min,max}Int return T #20574

2 Likes

Thanks for the link! I’ll read that