Short math notation, casting, clarity of math expressions

I’m fine with the cast, but it would be nice if we could at least avoid the need of writing the result type everywhere _ = float + @floatFromInt(large_int)
Since you don’t need @as in the other case I think your logic should be able to permit removing it here too.

5 Likes

This information is not hard to come by. While I see no harm in Zig documenting canonical facts like the significand width of an f32 (24), I also think that for programming domains where floats are required, this is fundamental domain knowledge which is well worth acquiring. There’s a lot of it, and mostly it doesn’t belong in the Zig docs.

I don’t think Zig’s documentation should, for example, show how two’s complement works. It’s fine to just say that Zig assumes negative numbers will use two’s complement. Anyone who then asks what’s two’s complement, and there’s a first time for everything! Will discover that the answer is available.

3 Likes

I’m going to create a PR for adding a table. It’s not going to explain the details, just a mapping of the floats and largest integer types that can coerce. Heck, I was the one that implemented the coercion a couple weeks ago, and I still find myself referring back to the source code to remember. :smile:

10 Likes

I think that strikes a nice balance. What’s obvious to whom varies considerably, and this doesn’t have the “and here’s what a float is” quality which is better avoided.

2 Likes