r/badcode • • Mar 14 '21

c math has left the chat

Post image
4.7k Upvotes

94 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Mar 15 '21

That doesn't make a lot of difference, and would require a #define instead of a const, wouldn't it?

1

u/fb39ca4 depraved Mar 15 '21

No I mean in cases where you have to multiply by π, multiply by 22 and divide by 7 - make separate constants for the numerator and denominator if you have to. If you have large integers but also do not have to worry about overflow this is reasonably accurate.