@amonakov@mastodon.gamedev.place
Post #2797284
2026-04-15 09:21 UTC
@lisyarus@mastodon.gamedev.place thanks for sharing this. What do you think about using double precision for intermediates when inputs are in single precision? For example, in your "vector length" example it's much cheaper to cast x, y, z to double instead of dividing by max(x, y, z) (in context of a CPU target, not GPU) — after the cast extreme exponent values do not pose an issue. This is exactly how hypotf in a modern C math library works — it's the double-precision hypot that needs to be fancier than that.
Replies (2)
-
@lisyarus@mastodon.gamedev.place 2026-04-16 07:40
@amonakov@mastodon.gamedev.place I was writing more with the idea that the code stays relevant regardless of the specific FP format. Of course, doubles will solve this specific case! I have this old habit of avoiding doubles, but afaik for most arithmetic ops they're as fast on modern CPUs.
-
@mbr@mastodon.gamedev.place 2026-04-16 14:07
@amonakov@mastodon.gamedev.place @lisyarus@mastodon.gamedev.place single precision real root(s) of the quadratic is another common thing that becomes trivial.