this post was submitted on 10 Apr 2025
11 points (100.0% liked)
C++
1976 readers
11 users here now
The center for all discussion and news regarding C++.
Rules
- Respect instance rules.
- Don't be a jerk.
- Please keep all posts related to C++.
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
The compiler can't replace every floating point division with a multiplication with the reciprocal. And it can't assume associativity. See also
-ffast-math
.You can do this:
return (double)steps * (2.0 * PI / 4096.0);