base:fixed_point_arithmethic
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | base:fixed_point_arithmethic [2015-04-17 04:31] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Fixed point arithmethic ====== | ||
+ | |||
+ | A fixed-point number representation is a number that has a fixed number of digits before and after the radix point (e.g. " | ||
+ | |||
+ | In terms of binary numbers, each magnitude bit represents a power of two, while each fractional bit represents an inverse power of two. Thus the first fractional bit is ½, the second is ¼, the third is ⅛ and so on. | ||
+ | |||
+ | 8:8 Fixed Point representation is the most straightforward approach (in fact the only sane approach when coding on the c64). | ||
+ | |||
+ | for example: | ||
+ | |||
+ | |||
+ | | ||
+ | |||
+ | < | ||
+ | |||
+ | |||
+ | represents the number: | ||
+ | |||
+ | integer part: | ||
+ | |||
+ | < | ||
+ | |||
+ | fractional part: | ||
+ | |||
+ | < | ||
+ | |||
+ | giving us: | ||
+ | |||
+ | < | ||
+ | |||
+ | It's easyer to think of a 8.8 fixed number in a way that you have a 1 byte integer part, and a 1 byte fractional part where the fractional part represents a number which is: fractional part* 1/ | ||
+ | |||
+ | Repeating the example above: | ||
+ | |||
+ | |||
+ | | ||
+ | |||
+ | < | ||
+ | |||
+ | |||
+ | < | ||
+ | |||
+ | |||
+ | You may totally forget about fractional parts and just threat the two 8 bit numbers as a straight representation of numbers from 0-65536: a 16 bit number when working with numbers like this. In reality a fixed point number will be always just a bunch of bits, and what makes it fixed point is only how you think about it. :) | ||
+ | |||
+ | |||
base/fixed_point_arithmethic.txt · Last modified: 2015-04-17 04:31 by 127.0.0.1