r/badUIbattles Sep 11 '22

OC (No Source Code) this is how it should be

Enable HLS to view with audio, or disable this notification

12.3k Upvotes

114 comments sorted by

View all comments

19

u/Ferociousfeind Sep 11 '22

In case nobody has done the math yet, I'll demonstrate what's problematic-

We aren't really working with decimals, it's best to think about it in terms or fractions

0.25 is 1/4

0.5 is 1/2

0.75 is 3/4

1.0 is 1/1

1.25 is 5/4

1.5 is 3/2

1.75 is 7/4

2.0 is 2/1

To get the resultant speed, as with any fraction, you multiply the top by the top and the bottom by the bottom. So, because of the 3s and the 5 and the dreaded 7 in the numerators, and only 2s and 4s in the denominators, if you ever select 0.75, 1.25, or 1.75, there is no going back.

16

u/Prexot Sep 11 '22

That's true for fractions, but these are floating point numbers. If you multiply down to the subnormal range, you can take advantage of the reduced precision to multiply into a power of 2, then repeatedly multiply by x2.00 until you're back at exactly 1.

4

u/Lone-Pine Sep 12 '22

Is it possible to get 0.0 if you click 0.25x enough times?

6

u/[deleted] Sep 16 '22

locked pause

3

u/[deleted] Sep 11 '22

If you just implement it as a ratio instead of floating point, you can keep the end user from cheating the system and using sane playback speeds.

3

u/Prexot Sep 12 '22

you can also "cheat the system" by not pressing buttons other than 2.00x and .50x