filmov
tv
Fixed Point Maths Explained - Retro Programming
Показать описание
A video explaining how fixed point maths works and why it is useful on CPUs that have no floating point units.
A written version of this is available on my website, linked below
Fixed point maths is a way to deal with decimal numbers, on systems where they don't have the ability to use decimals. The basic concept is to scale all numbers up by a certain amount to remove any decimal parts of the number. Then you can work with whole numbers only, scaling back down when needed.
What scale you use depends on the range of numbers needed for a particular situation. It can also depend on what the hardware is best at managing. A Z80 CPU for example can work with 16 bit values reasonably easily. And if you’re not trying to do complex accurate scientific calculations, the resolution of your machine’s screen is likely to be a factor as well.
But if you want a quick one to use, this explanation uses what is called 8.8 fixed numbers. That is a 16 bit value where the upper 8 bits are the whole number and the lower 8 bits the fractional part. With an imaginary binary point in the middle.
Chapters
00:17 Maths is hard
00:56 Floating point maths
01:45 I have more videos!
03:53 What we're trying to do
04:57 Example with money
06:39 Introducing fixed point maths
08:28 negative numbers
10:39 Explaining fixed point
15:03 Summary
A written version of this is available on my website, linked below
Fixed point maths is a way to deal with decimal numbers, on systems where they don't have the ability to use decimals. The basic concept is to scale all numbers up by a certain amount to remove any decimal parts of the number. Then you can work with whole numbers only, scaling back down when needed.
What scale you use depends on the range of numbers needed for a particular situation. It can also depend on what the hardware is best at managing. A Z80 CPU for example can work with 16 bit values reasonably easily. And if you’re not trying to do complex accurate scientific calculations, the resolution of your machine’s screen is likely to be a factor as well.
But if you want a quick one to use, this explanation uses what is called 8.8 fixed numbers. That is a 16 bit value where the upper 8 bits are the whole number and the lower 8 bits the fractional part. With an imaginary binary point in the middle.
Chapters
00:17 Maths is hard
00:56 Floating point maths
01:45 I have more videos!
03:53 What we're trying to do
04:57 Example with money
06:39 Introducing fixed point maths
08:28 negative numbers
10:39 Explaining fixed point
15:03 Summary
Комментарии