Content deleted Content added
Matthiaspaul (talk | contribs) |
|||
Line 1:
{{Refimprove|date=December 2009}}
'''Binary scaling''' is a [[computer programming]] technique used typically in embedded [[C (programming language)|C]], [[Digital signal processing|DSP]] and [[assembly language|assembler]] programs to implement pseudo [[floating point]] operations by using the native [[integer]] arithmetic of the processor.
==Overview==
A representation of a floating point value using binary scaling is more precise than a floating point representation occupying the same number of bits, but cannot represent values beyond the range that it represents, thus more easily leading to [[arithmetic overflow]] during computation. Implementation of operations using integer arithmetic instructions is often (but not always) faster than the corresponding floating point instructions.
A position for the 'binary point' is chosen for each variable to be represented, and binary shifts associated with arithmetic operations are adjusted accordingly. The Binary scaling corresponds in [[Q (number format)]] to the first digit, i.e. Q1.15 is a 16 bit integer
scaled with one bit as integer and fifteen as fractional. A Bscal 1 or Q1.15 number would represent approx 1.999 to -2.0 as [[floating point]].
To give an example, a common way to use [[Arbitrary-precision arithmetic|integer arithmetic]] to simulate floating point, using 32 bit numbers, is to multiply the coefficients by 65536.
|