Unity vs. Floating Point

Unity’s number crunching got called out, and the comments turned into a group therapy session

TLDR: A developer found that Unity often handles common math in a slower, roundabout way, while a newer built-in option can be much faster. Commenters turned that into a mix of awe, old grudges, and horror stories, with some saying it explains years of weird behavior.

A tiny tip about game-making math turned into a full-blown “wait, it’s been doing WHAT?” moment for the Unity crowd. The big reveal: in many cases, Unity’s built-in math tools take the scenic route, doing extra work before giving you the same answer. Swap in the newer .NET option and, in simple tests, things got noticeably faster. For developers, that’s not just a nerdy footnote — it’s the kind of discovery that makes people stare into the middle distance and rethink old projects.

And the community absolutely ran with it. One camp was impressed by the deep dive and loved seeing the low-level proof, with one commenter basically cheering, “show me the assembly breakdown.” Another camp instantly turned this into a Unity grievance thread, dredging up old pain. The mood was less “huh, neat” and more “I KNEW something felt cursed.” One user blamed strange physics behavior near the center of the game world on this whole floating-point mess, describing it like a creepy “gravity well effect.” That’s the kind of comment that turns a performance post into a campfire ghost story.

Then came the veteran bitterness: a commenter said they still haven’t forgiven Unity for another floating-point trap involving loading progress, which is exactly the flavor of long-memory outrage the internet loves. The jokes weren’t really jokes so much as battle scars delivered with a smirk. The overall vibe? Unity didn’t just start a math debate — it accidentally reopened the comments section’s trauma vault.

Key Points

  • The article says many UnityEngine.Mathf float operations internally use double precision before converting results back to float, while System.MathF uses float-native implementations.
  • System.MathF was introduced in .NET Core 2.0 in 2017, but the article says Unity has not updated many corresponding Mathf methods to single-precision implementations.
  • The article states that Unity.Mathematics, despite being a newer package introduced in 2019, also routes many float trigonometric and exponential functions through double-precision C# implementations.
  • According to the article, Unity’s Mono runtime performs float math in double precision, unlike IL2CPP and Burst, which do not share that behavior.
  • In the article’s benchmark inside the Unity editor on Windows, System.MathF.Sqrt ran faster than UnityEngine.Mathf.Sqrt in both normal and Release-mode editor tests.

Hottest takes

"I still have not forgiven Unity for the floating point footgun" — corysama
"It has a weird gravity well effect if you get too near it" — Zarathruster
"It’s awesome they were able to show the assembly breakdown" — koolala
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.