hachyderm.io is one of the many independent Mastodon servers you can use to participate in the fediverse.
Hachyderm is a safe space, LGBTQIA+ and BLM, primarily comprised of tech industry professionals world wide. Note that many non-user account types have restrictions - please see our About page.

Administered by:

Server stats:

9.5K
active users

Šimon Tóth

When mixing integers with floating point types in arithmetic expressions, the result of the expression is always a floating point type.

If multiple floating point types are present, the result of the expression is the highest present floating point type: float, double or long double (in that order).

Compiler Explorer link: compiler-explorer.com/z/rn5Tnb

@simontoth so hard to look at initialization of y with a value that is double, especially one that cannot be represented accurately.
My recommendation is to either always use suffix f or to not use floats, only doubles. Such simple lazyness can lead to crazy bugs.
Don't cause youself extra fp errors, you'll get enouth of them anyway :)

@aurisc4 Good point, one more reason for "almost always auto". 😉