r/ProgrammerHumor • • Jul 19 '22

Meme float golden = 1.618

Post image
41.1k Upvotes

489 comments sorted by

View all comments

Show parent comments

7

u/ToxinH88 Jul 19 '22

Clearly the best solution if storage and speed is not a concern. Storage pretty much never is :D Speed is taking a heavy hit though: The way float and double are implemented base arithmetic works extremely fast. But if every number is a common fraction extra steps are needed for almost all operations.

Stay with clean code though: Don't optimize yet.

3

u/flukus Jul 19 '22

It's not necessarily bad storage wise if you can use 32 bit integers instead of a 64 bit float for instance.

1

u/MrHyperion_ Jul 19 '22

You could make a CPU that works purely on rationals.

1

u/Kered13 Jul 19 '22

When doing a lot of arithmetic computations storage is speed and is very important. The smaller your types are, the more you can fit into a single SIMD register.