Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Fixed-point arithmetic
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Choice of scaling factors=== For greater efficiency, scaling factors are often chosen to be [[exponentiation|powers]] (positive or negative) of the base ''b'' used to represent the integers internally. However, often the best scaling factor is dictated by the application. Thus one often uses scaling factors that are powers of 10 (e.g. 1/100 for dollar values), for human convenience, even when the integers are represented internally in binary. Decimal scaling factors also mesh well with the [[International System of Units|metric (SI) system]], since the choice of the fixed-point scaling factor is often equivalent to the choice of a unit of measure (like [[centimeter]]s or [[micron]]s instead of [[meter]]s). However, other scaling factors may be used occasionally, e.g. a fractional amount of hours may be represented as an integer number of seconds; that is, as a fixed-point number with scale factor of 1/3600. Even with the most careful rounding, fixed-point values represented with a scaling factor ''S'' may have an error of up to Β±0.5 in the stored integer, that is, Β±0.5 ''S'' in the value. Therefore, smaller scaling factors generally produce more accurate results. On the other hand, a smaller scaling factor means a smaller range of the values that can be stored in a given program variable. The maximum fixed-point value that can be stored into a variable is the largest integer value that can be stored into it, multiplied by the scaling factor; and similarly for the minimum value. For example, the table below gives the implied scaling factor ''S'', the minimum and maximum representable values ''V''<sub>min</sub> and ''V''<sub>max</sub>, and the accuracy ''Ξ΄'' = ''S''/2 of values that could be represented in 16-bit signed binary fixed point format, depending on the number ''f'' of implied fraction bits. {| class= "wikitable" style="margin:0 0 0 1em; float:center;" |+ Parameters of some 16-bit signed binary fixed-point formats |- ! ''f'' !! ''S'' !! ''Ξ΄'' !! ''V''<sub>min</sub> !!''V''<sub>max</sub> |- | β3 || 1/2<sup>β3</sup> = 8 || 4 || β{{thinspace|262|144}} || +{{thinspace|262|136}} |- | 0 || 1/2<sup>0</sup> = 1 || 0.5 || β{{thinspace|32|768}} || +{{thinspace|32|767}} |- | 5 || 1/2<sup>5</sup> = 1/32 || < 0.016 || β1024.{{thinspace|000|00}} || +1023.{{thinspace|968|75}} |- | 14 || 1/2<sup>14</sup> = 1/{{thinspace|16|384}} || < 0.{{thinspace|000|031}} || β2.{{thinspace|000|000|000|000|00}} ||+1.{{thinspace|999|938|964|843|75}} |- | 15 || 1/2<sup>15</sup> = 1/{{thinspace|32|768}} || < 0.{{thinspace|000|016}} || β1.{{thinspace|000|000|000|000|000}} ||+0.{{thinspace|999|969|482|421|875}} |- | 16 || 1/2<sup>16</sup> = 1/{{thinspace|65|536}} || < 0.{{thinspace|000|008}} || β0.{{thinspace|500|000|000|000|000|0}} ||+0.{{thinspace|499|984|741|210|937|5}} |- | 20 || 1/2<sup>20</sup> = 1/{{thinspace|1|048|576}} || < 0.{{thinspace|000|000|5}} || β0.{{thinspace|031|250|000|000|000|000|00}} || +0.{{thinspace|031|249|046|325|683|593|75}} |} Fixed-point formats with scaling factors of the form 2<sup>''n''</sup>β1 (namely 1, 3, 7, 15, 31, etc.) have been said to be appropriate for image processing and other digital signal processing tasks. They are supposed to provide more consistent conversions between fixed- and floating-point values than the usual 2<sup>''n''</sup> scaling. The [[Julia (programming language)|Julia]] programming language implements both versions.<ref name="julia"/>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)