3 ms·
Real-time displays often need to show floating point numbers as they change. As a simple example, the time remaining display of a music player ticks down as the
by herodotus 8y ago
Real-time displays often need to show floating point numbers as they change. As a simple example, the time remaining display of a music player ticks down as the music plays. Now in this case, it is easy to fake it by using integers and then placing the decimal point, but if you were controlling something complex in real time you might not be able to do this as easily.
- wongarsu 8y ago> it is easy to fake it by using integers and then placing the decimal point That's not "faking it", that using fixed point numbers [1]. They are a great alternative if the numbers stay in roughly the same magnitude, and are much saner when dealing with e.g. money. 1: https://en.wikipedia.org/wiki/Fixed-point_arithmetic https://en.wikipedia.org/wiki/Fixed-point_arithmetic
- herodotus 8y agoGood point, and thanks. But if you are doing a real-time display (like an industrial controller, for example), you may not be able to choose a fixed point number as your source. I chose the music time example first because it is a common use of a number that needs to change in (almost) real time.