Unexpected output when converting to an integer with int()

In general, it's best to avoid floats anywhere you can use integers. For one, go browse the avr-libc handbook, particularly the math stuff. You'll find a lot of it uses floats as parameters by default. Since there's no floating-point hardware in an AVR mega or tiny, that all has to be done via software emulation, which is extra code bloat that you probably didn't need for your intended application.

For that reason, be aware of the math functions you use and try to implement them in more efficient ways if you can. E.g., definitely use shifts to do powers of 2. You'll get a more accurate result, it'll execute faster (a relative term), and assuming you don't use floats anywhere else, it'll save all the flash space required to include the fp math library.

Naturally, when you need non-integer values and can't get by with fixed-point math, well ya godda do whatcha godda do. And none of this applies in test cases and matters of curiosity like in this thread.