SlideShare una empresa de Scribd logo
1 de 21
Descargar para leer sin conexión
Fixed-point arithmetic
David Barina
May 23, 2014
David Barina Fixed-point May 23, 2014 1 / 21
Integer
1 1 1 1
1 0 0 0
0 1 1 1
0 0 0 0
15
7
8
0
…
…
1 1 1 1
1 0 0 0
0 1 1 1
0 0 0 0
−1
7
−8
0
…
…
David Barina Fixed-point May 23, 2014 2 / 21
Floating point
a × 2b
sign exponent (8 bits) fraction (23 bits)
02331
0 0 1 1 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = 0.15625
30 22 (bit index)
David Barina Fixed-point May 23, 2014 3 / 21
Fixed point
1 1 1 1
1 0 0 0
0 1 1 1
0 0 0 0
−0.0625
7.9375
−8.0000
0.0000
…
…
1 1 1 1
0 0 0 0
1 1 1 1
0 0 0 0
1 1 1 1
1 0 0 0
0 1 1 1
0 0 0 0
15.9375
7.9375
8.0000
0.0000
…
…
1 1 1 1
0 0 0 0
1 1 1 1
0 0 0 0
David Barina Fixed-point May 23, 2014 4 / 21
Benefits
Advantages
instructions for the integer arithmetic are sufficient
no need for FP instructions (FPU, SSE)
constant resolution in the whole range
higher accuracy (small dynamic ranges)
Drawbacks
limited range
overflow
less accuracy (greater dynamic ranges)
David Barina Fixed-point May 23, 2014 5 / 21
Notation
Qm.n
Q3.4 1 sign bit, 3 integer, 4 fractional bits
Q1.30 32 bits in total
Q15.16 32 bits in total
David Barina Fixed-point May 23, 2014 6 / 21
Examples
type name bits resolution range
INT integer 32 1 ±231 ≈ ±2.1 × 109
FP single 32 2−23 ≈ 1.2 × 10−7 ±2128 ≈ ±3.4 × 1038
FX Q15.16 32 2−16 ≈ 1.5 × 10−5 ±215 ≈ ±3.2 × 104
FX Q1.30 32 2−30 ≈ 9.3 × 10−10 ±2
David Barina Fixed-point May 23, 2014 7 / 21
Conversion (Qm.n)
INT → FX
y = x << n;
FX → INT
k = 1 << (n-1);
y = (x + k) >> n;
FP → FX
#include <math.h>
y = round( x * (1 << n) );
FX → FP
y = (double)x / (1 << n);
David Barina Fixed-point May 23, 2014 8 / 21
Rounding (Qm.n)
Truncation
int floor(int x) {
return x & ˜((1<<n)-1);
}
Ceiling
int ceil(int x) {
return floor(x + ((1<<n)-1));
}
Rounding
int round(int x) {
return floor(x + (1<<(n-1)));
}
David Barina Fixed-point May 23, 2014 9 / 21
Operations (Qm.n)
Zero
z = 0;
Unit
z = 1 << n;
One half
z = 1 << (n-1);
Negation
z = -x;
Absolute value
z = abs(x);
David Barina Fixed-point May 23, 2014 10 / 21
Operations (Qm.n)
Addition
z = x + y;
Subtraction
z = x - y;
Multiplication by an integer
z = x * i;
Multiplication
k = 1 << (n-1);
z = ( x * y + k ) >> n;
Division
z = (x << n) / y;
David Barina Fixed-point May 23, 2014 11 / 21
Multiplication (Q15.16)
Multiply a.b × c.d
uint32_t result_low = (b * d);
uint32_t result_mid = (a * d) + (b * c);
uint32_t result_high = (a * c);
uint32_t result = (result_high << 16) + result_mid
+ (result_low >> 16);
David Barina Fixed-point May 23, 2014 12 / 21
Trick
Division by a constant
a/b → a × c c = 1/b
z = a / 5;
// 1/5 = 0.2 = 858993459 in Q31.32
z = (a * 858993459) >> 32;
David Barina Fixed-point May 23, 2014 13 / 21
Functions
Sine by Taylor series [libfixmath]
sin(x) = x −
x3
3!
+
x5
5!
−
x7
!7
+
x9
!9
−
x11
11!
Sine by polynomial [Fixmath]
16 segments, polynomial of degree 4, Remez alg.
sin(x) = c0 + c1x1
+ c2x2
+ c3x3
+ c4x4
David Barina Fixed-point May 23, 2014 14 / 21
Functions
Inverse square root [Fixmath]
y = 1/
√
x
Newton’s method
x → a × 2b
y = y (3 − a y2
)/2
Square root [Fixmath]
x → a × 2b
c = 1/
√
a × a =
√
a
y ← c × 2b/2
David Barina Fixed-point May 23, 2014 15 / 21
Functions
Square root [libfixmath]
abacus algorithm
while (one != 0) {
if (x >= y + one) {
x = x - (y + one);
y = y + 2 * one;
}
y /= 2;
one /= 4;
}
David Barina Fixed-point May 23, 2014 16 / 21
Functions
Reciprocal value [Fixmath]
y = 1/x
Newton’s method
x → a × 2b
y = y (2 − ay)
Division
z = x/y =⇒ z = x × (1/y)
David Barina Fixed-point May 23, 2014 17 / 21
Functions
Exponential function [libfixmath]
x > 0 =⇒ e−x = 1/ex
ex
=
∞
n=0
xn
n!
Natural logarithm [libfixmath]
Newton’s method
y = y +
x − ey
ey
David Barina Fixed-point May 23, 2014 18 / 21
Functions
Base-2 logarithm [libfixmath]
y = log2(x) |Qm.n
y = 0;
while( x >= 2 ) {
x /= 2;
y++;
}
for_each(n) {
x *= x;
y *= 2;
if( x >= 2 ) {
x /= 2;
y++;
}
}
David Barina Fixed-point May 23, 2014 19 / 21
Functions
Base-2 logarithm [Fixmath]
y = log2(1 + x)
16 segments, polynomial of degree 4/11, Remez alg.
Base-2 exponential [Fixmath]
y = 2x
1/32 segments, polynomial of degree 7/3, Remez alg.
David Barina Fixed-point May 23, 2014 20 / 21
Libraries
libfixmath http://code.google.com/p/libfixmath/
Fixmath http://savannah.nongnu.org/projects/fixmath/
David Barina Fixed-point May 23, 2014 21 / 21

Más contenido relacionado

La actualidad más candente

Ring Counter.pptx
Ring Counter.pptxRing Counter.pptx
Ring Counter.pptxhepzijustin
 
Derivation of Simpson's 1/3 rule
Derivation of Simpson's 1/3 ruleDerivation of Simpson's 1/3 rule
Derivation of Simpson's 1/3 ruleHapPy SumOn
 
Dlc{binary to gray code conversion} ppt
Dlc{binary to gray code conversion} pptDlc{binary to gray code conversion} ppt
Dlc{binary to gray code conversion} pptTanish Gupta
 
8085 data transfer instruction set
8085 data transfer instruction set8085 data transfer instruction set
8085 data transfer instruction setprashant1271
 
adder and subtractor
 adder and subtractor adder and subtractor
adder and subtractorUnsa Shakir
 
Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)Piyush Rochwani
 
Complements of numbers
Complements of numbersComplements of numbers
Complements of numbersKiriti Varkur
 
Nand and nor as a universal gates
Nand and nor as a universal gatesNand and nor as a universal gates
Nand and nor as a universal gatesKaushal Shah
 
LOGIC GATES VIDEO LECTURE IN HINDI|OR GATE,AND GATE &NOT GATE|LOGIC DIAGRAM &...
LOGIC GATES VIDEO LECTURE IN HINDI|OR GATE,AND GATE &NOT GATE|LOGIC DIAGRAM &...LOGIC GATES VIDEO LECTURE IN HINDI|OR GATE,AND GATE &NOT GATE|LOGIC DIAGRAM &...
LOGIC GATES VIDEO LECTURE IN HINDI|OR GATE,AND GATE &NOT GATE|LOGIC DIAGRAM &...Prasant Kumar
 
Presentation on Karnaugh Map
Presentation  on Karnaugh MapPresentation  on Karnaugh Map
Presentation on Karnaugh MapKawsar Ahmed
 
Computer Oragnization Flipflops
Computer Oragnization FlipflopsComputer Oragnization Flipflops
Computer Oragnization FlipflopsVanitha Chandru
 

La actualidad más candente (20)

Encoder and decoder
Encoder and decoderEncoder and decoder
Encoder and decoder
 
Subtractor (1)
Subtractor (1)Subtractor (1)
Subtractor (1)
 
Ring Counter.pptx
Ring Counter.pptxRing Counter.pptx
Ring Counter.pptx
 
Bcd
BcdBcd
Bcd
 
Derivation of Simpson's 1/3 rule
Derivation of Simpson's 1/3 ruleDerivation of Simpson's 1/3 rule
Derivation of Simpson's 1/3 rule
 
Dlc{binary to gray code conversion} ppt
Dlc{binary to gray code conversion} pptDlc{binary to gray code conversion} ppt
Dlc{binary to gray code conversion} ppt
 
Sop and pos
Sop and posSop and pos
Sop and pos
 
Binary codes
Binary codesBinary codes
Binary codes
 
Ripple Carry Adder
Ripple Carry AdderRipple Carry Adder
Ripple Carry Adder
 
Multiplexers
MultiplexersMultiplexers
Multiplexers
 
8085 data transfer instruction set
8085 data transfer instruction set8085 data transfer instruction set
8085 data transfer instruction set
 
adder and subtractor
 adder and subtractor adder and subtractor
adder and subtractor
 
Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)Booth’s algorithm.(a014& a015)
Booth’s algorithm.(a014& a015)
 
Complements of numbers
Complements of numbersComplements of numbers
Complements of numbers
 
Bcd adder
Bcd adderBcd adder
Bcd adder
 
Nand and nor as a universal gates
Nand and nor as a universal gatesNand and nor as a universal gates
Nand and nor as a universal gates
 
LOGIC GATES VIDEO LECTURE IN HINDI|OR GATE,AND GATE &NOT GATE|LOGIC DIAGRAM &...
LOGIC GATES VIDEO LECTURE IN HINDI|OR GATE,AND GATE &NOT GATE|LOGIC DIAGRAM &...LOGIC GATES VIDEO LECTURE IN HINDI|OR GATE,AND GATE &NOT GATE|LOGIC DIAGRAM &...
LOGIC GATES VIDEO LECTURE IN HINDI|OR GATE,AND GATE &NOT GATE|LOGIC DIAGRAM &...
 
MULTIPLEXER
MULTIPLEXERMULTIPLEXER
MULTIPLEXER
 
Presentation on Karnaugh Map
Presentation  on Karnaugh MapPresentation  on Karnaugh Map
Presentation on Karnaugh Map
 
Computer Oragnization Flipflops
Computer Oragnization FlipflopsComputer Oragnization Flipflops
Computer Oragnization Flipflops
 

Destacado

Integer Representation
Integer RepresentationInteger Representation
Integer Representationgavhays
 
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...Silicon Mentor
 
Decimal arithmetic in Processors
Decimal arithmetic in ProcessorsDecimal arithmetic in Processors
Decimal arithmetic in ProcessorsPeeyush Pashine
 
digital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed pointdigital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed pointRai University
 
Optimized Floating-point Complex number multiplier on FPGA
Optimized Floating-point Complex number multiplier on FPGAOptimized Floating-point Complex number multiplier on FPGA
Optimized Floating-point Complex number multiplier on FPGADr. Pushpa Kotipalli
 
Design and Implementation of High Speed Area Efficient Double Precision Float...
Design and Implementation of High Speed Area Efficient Double Precision Float...Design and Implementation of High Speed Area Efficient Double Precision Float...
Design and Implementation of High Speed Area Efficient Double Precision Float...IOSR Journals
 
Floating point units
Floating point unitsFloating point units
Floating point unitsdipugovind
 
Quick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representationQuick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representationRitu Ranjan Shrivastwa
 
Floating point ALU using VHDL implemented on FPGA
Floating point ALU using VHDL implemented on FPGAFloating point ALU using VHDL implemented on FPGA
Floating point ALU using VHDL implemented on FPGAAzhar Syed
 

Destacado (16)

06 floating point
06 floating point06 floating point
06 floating point
 
Integer Representation
Integer RepresentationInteger Representation
Integer Representation
 
Representation of Real Numbers
Representation of Real NumbersRepresentation of Real Numbers
Representation of Real Numbers
 
Exceptions in python
Exceptions in pythonExceptions in python
Exceptions in python
 
Class10
Class10Class10
Class10
 
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...
Design and Implementation of Single Precision Pipelined Floating Point Co-Pro...
 
Decimal arithmetic in Processors
Decimal arithmetic in ProcessorsDecimal arithmetic in Processors
Decimal arithmetic in Processors
 
digital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed pointdigital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed point
 
Optimized Floating-point Complex number multiplier on FPGA
Optimized Floating-point Complex number multiplier on FPGAOptimized Floating-point Complex number multiplier on FPGA
Optimized Floating-point Complex number multiplier on FPGA
 
Design and Implementation of High Speed Area Efficient Double Precision Float...
Design and Implementation of High Speed Area Efficient Double Precision Float...Design and Implementation of High Speed Area Efficient Double Precision Float...
Design and Implementation of High Speed Area Efficient Double Precision Float...
 
Data representation
Data representationData representation
Data representation
 
Floating point units
Floating point unitsFloating point units
Floating point units
 
Quick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representationQuick tutorial on IEEE 754 FLOATING POINT representation
Quick tutorial on IEEE 754 FLOATING POINT representation
 
Floating point ALU using VHDL implemented on FPGA
Floating point ALU using VHDL implemented on FPGAFloating point ALU using VHDL implemented on FPGA
Floating point ALU using VHDL implemented on FPGA
 
Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
 
Sampling design
Sampling designSampling design
Sampling design
 

Similar a Fixed-point arithmetic guide

Bit Twiddling Hacks: Integers
Bit Twiddling Hacks: IntegersBit Twiddling Hacks: Integers
Bit Twiddling Hacks: IntegersDavid Bařina
 
Solution Manual : Chapter - 06 Application of the Definite Integral in Geomet...
Solution Manual : Chapter - 06 Application of the Definite Integral in Geomet...Solution Manual : Chapter - 06 Application of the Definite Integral in Geomet...
Solution Manual : Chapter - 06 Application of the Definite Integral in Geomet...Hareem Aslam
 
Calculo purcell 9 ed solucionario
Calculo  purcell  9 ed   solucionarioCalculo  purcell  9 ed   solucionario
Calculo purcell 9 ed solucionarioLuis Manuel Leon
 
51541 0131469657 ism-0
51541 0131469657 ism-051541 0131469657 ism-0
51541 0131469657 ism-0Ani_Agustina
 
Gaussian quadratures
Gaussian quadraturesGaussian quadratures
Gaussian quadraturesTarun Gehlot
 
Formulario Geometria Analitica.pdf
Formulario Geometria Analitica.pdfFormulario Geometria Analitica.pdf
Formulario Geometria Analitica.pdfAntonio Guasco
 
College algebra real mathematics real people 7th edition larson solutions manual
College algebra real mathematics real people 7th edition larson solutions manualCollege algebra real mathematics real people 7th edition larson solutions manual
College algebra real mathematics real people 7th edition larson solutions manualJohnstonTBL
 
Application of derivatives 2 maxima and minima
Application of derivatives 2  maxima and minimaApplication of derivatives 2  maxima and minima
Application of derivatives 2 maxima and minimasudersana viswanathan
 
1st period exam review(w)
1st period exam review(w)1st period exam review(w)
1st period exam review(w)Joshua Gerrard
 
Strategic Intervention Materials
Strategic Intervention MaterialsStrategic Intervention Materials
Strategic Intervention MaterialsBrian Mary
 
Solution Manual Engineering Signals and Systems by Ulaby & Yagle
Solution Manual Engineering Signals and Systems by Ulaby & YagleSolution Manual Engineering Signals and Systems by Ulaby & Yagle
Solution Manual Engineering Signals and Systems by Ulaby & Yaglespaceradar35
 
Mathmatics (Algebra,inequalities, Sequences, variation and indices
Mathmatics (Algebra,inequalities, Sequences, variation and indicesMathmatics (Algebra,inequalities, Sequences, variation and indices
Mathmatics (Algebra,inequalities, Sequences, variation and indicesSneha Gori
 
51542 0131469657 ism-1
51542 0131469657 ism-151542 0131469657 ism-1
51542 0131469657 ism-1Ani_Agustina
 
College algebra in context 5th edition harshbarger solutions manual
College algebra in context 5th edition harshbarger solutions manualCollege algebra in context 5th edition harshbarger solutions manual
College algebra in context 5th edition harshbarger solutions manualAnnuzzi19
 
sim-140907230908-phpapp01.pptx
sim-140907230908-phpapp01.pptxsim-140907230908-phpapp01.pptx
sim-140907230908-phpapp01.pptxJeffreyEnriquez10
 

Similar a Fixed-point arithmetic guide (20)

Bit Twiddling Hacks: Integers
Bit Twiddling Hacks: IntegersBit Twiddling Hacks: Integers
Bit Twiddling Hacks: Integers
 
Solution Manual : Chapter - 06 Application of the Definite Integral in Geomet...
Solution Manual : Chapter - 06 Application of the Definite Integral in Geomet...Solution Manual : Chapter - 06 Application of the Definite Integral in Geomet...
Solution Manual : Chapter - 06 Application of the Definite Integral in Geomet...
 
02 basics i-handout
02 basics i-handout02 basics i-handout
02 basics i-handout
 
Calculo purcell 9 ed solucionario
Calculo  purcell  9 ed   solucionarioCalculo  purcell  9 ed   solucionario
Calculo purcell 9 ed solucionario
 
51541 0131469657 ism-0
51541 0131469657 ism-051541 0131469657 ism-0
51541 0131469657 ism-0
 
Gaussian quadratures
Gaussian quadraturesGaussian quadratures
Gaussian quadratures
 
Formulario Geometria Analitica.pdf
Formulario Geometria Analitica.pdfFormulario Geometria Analitica.pdf
Formulario Geometria Analitica.pdf
 
College algebra real mathematics real people 7th edition larson solutions manual
College algebra real mathematics real people 7th edition larson solutions manualCollege algebra real mathematics real people 7th edition larson solutions manual
College algebra real mathematics real people 7th edition larson solutions manual
 
Application of derivatives 2 maxima and minima
Application of derivatives 2  maxima and minimaApplication of derivatives 2  maxima and minima
Application of derivatives 2 maxima and minima
 
Numerical Methods and Analysis
Numerical Methods and AnalysisNumerical Methods and Analysis
Numerical Methods and Analysis
 
1st period exam review(w)
1st period exam review(w)1st period exam review(w)
1st period exam review(w)
 
Leidy rivadeneira deber_1
Leidy rivadeneira deber_1Leidy rivadeneira deber_1
Leidy rivadeneira deber_1
 
Strategic Intervention Materials
Strategic Intervention MaterialsStrategic Intervention Materials
Strategic Intervention Materials
 
Solution Manual Engineering Signals and Systems by Ulaby & Yagle
Solution Manual Engineering Signals and Systems by Ulaby & YagleSolution Manual Engineering Signals and Systems by Ulaby & Yagle
Solution Manual Engineering Signals and Systems by Ulaby & Yagle
 
Mathmatics (Algebra,inequalities, Sequences, variation and indices
Mathmatics (Algebra,inequalities, Sequences, variation and indicesMathmatics (Algebra,inequalities, Sequences, variation and indices
Mathmatics (Algebra,inequalities, Sequences, variation and indices
 
51542 0131469657 ism-1
51542 0131469657 ism-151542 0131469657 ism-1
51542 0131469657 ism-1
 
College algebra in context 5th edition harshbarger solutions manual
College algebra in context 5th edition harshbarger solutions manualCollege algebra in context 5th edition harshbarger solutions manual
College algebra in context 5th edition harshbarger solutions manual
 
Sample question paper 2 with solution
Sample question paper 2 with solutionSample question paper 2 with solution
Sample question paper 2 with solution
 
sim-140907230908-phpapp01.pptx
sim-140907230908-phpapp01.pptxsim-140907230908-phpapp01.pptx
sim-140907230908-phpapp01.pptx
 
Gr 11 equations
Gr 11   equationsGr 11   equations
Gr 11 equations
 

Más de David Bařina

Lossy Light Field Compression
Lossy Light Field CompressionLossy Light Field Compression
Lossy Light Field CompressionDavid Bařina
 
Mathematical curiosities
Mathematical curiositiesMathematical curiosities
Mathematical curiositiesDavid Bařina
 
New Transforms for JPEG Format
New Transforms for JPEG FormatNew Transforms for JPEG Format
New Transforms for JPEG FormatDavid Bařina
 
Discrete Wavelet Transforms on Parallel Architectures
Discrete Wavelet Transforms on Parallel ArchitecturesDiscrete Wavelet Transforms on Parallel Architectures
Discrete Wavelet Transforms on Parallel ArchitecturesDavid Bařina
 
Parallel Implementation of the 2-D Discrete Wavelet Transform
Parallel Implementation of the 2-D Discrete Wavelet TransformParallel Implementation of the 2-D Discrete Wavelet Transform
Parallel Implementation of the 2-D Discrete Wavelet TransformDavid Bařina
 
Parallel Wavelet Schemes for Images
Parallel Wavelet Schemes for ImagesParallel Wavelet Schemes for Images
Parallel Wavelet Schemes for ImagesDavid Bařina
 
Single-Loop Software Architecture for JPEG 2000
Single-Loop Software Architecture for JPEG 2000Single-Loop Software Architecture for JPEG 2000
Single-Loop Software Architecture for JPEG 2000David Bařina
 
Lifting Scheme Cores for Wavelet Transform
Lifting Scheme Cores for Wavelet TransformLifting Scheme Cores for Wavelet Transform
Lifting Scheme Cores for Wavelet TransformDavid Bařina
 
Real-Time 3-D Wavelet Lifting
Real-Time 3-D Wavelet LiftingReal-Time 3-D Wavelet Lifting
Real-Time 3-D Wavelet LiftingDavid Bařina
 
IIR aproximace Gaussovy funkce
IIR aproximace Gaussovy funkceIIR aproximace Gaussovy funkce
IIR aproximace Gaussovy funkceDavid Bařina
 
Akcelerace DWT pomocí SIMD
Akcelerace DWT pomocí SIMDAkcelerace DWT pomocí SIMD
Akcelerace DWT pomocí SIMDDavid Bařina
 
Wavelet Lifting on Application Specific Vector Processor
Wavelet Lifting on Application Specific Vector ProcessorWavelet Lifting on Application Specific Vector Processor
Wavelet Lifting on Application Specific Vector ProcessorDavid Bařina
 

Más de David Bařina (19)

CCSDS 122.0
CCSDS 122.0CCSDS 122.0
CCSDS 122.0
 
Lossy Light Field Compression
Lossy Light Field CompressionLossy Light Field Compression
Lossy Light Field Compression
 
Mathematical curiosities
Mathematical curiositiesMathematical curiosities
Mathematical curiosities
 
C/C++ tricks
C/C++ tricksC/C++ tricks
C/C++ tricks
 
New Transforms for JPEG Format
New Transforms for JPEG FormatNew Transforms for JPEG Format
New Transforms for JPEG Format
 
JPEG
JPEGJPEG
JPEG
 
Discrete Wavelet Transforms on Parallel Architectures
Discrete Wavelet Transforms on Parallel ArchitecturesDiscrete Wavelet Transforms on Parallel Architectures
Discrete Wavelet Transforms on Parallel Architectures
 
Parallel Implementation of the 2-D Discrete Wavelet Transform
Parallel Implementation of the 2-D Discrete Wavelet TransformParallel Implementation of the 2-D Discrete Wavelet Transform
Parallel Implementation of the 2-D Discrete Wavelet Transform
 
Parallel Wavelet Schemes for Images
Parallel Wavelet Schemes for ImagesParallel Wavelet Schemes for Images
Parallel Wavelet Schemes for Images
 
Single-Loop Software Architecture for JPEG 2000
Single-Loop Software Architecture for JPEG 2000Single-Loop Software Architecture for JPEG 2000
Single-Loop Software Architecture for JPEG 2000
 
Lifting Scheme Cores for Wavelet Transform
Lifting Scheme Cores for Wavelet TransformLifting Scheme Cores for Wavelet Transform
Lifting Scheme Cores for Wavelet Transform
 
Real-Time 3-D Wavelet Lifting
Real-Time 3-D Wavelet LiftingReal-Time 3-D Wavelet Lifting
Real-Time 3-D Wavelet Lifting
 
Wavelet News
Wavelet NewsWavelet News
Wavelet News
 
IIR aproximace Gaussovy funkce
IIR aproximace Gaussovy funkceIIR aproximace Gaussovy funkce
IIR aproximace Gaussovy funkce
 
Akcelerace DWT pomocí SIMD
Akcelerace DWT pomocí SIMDAkcelerace DWT pomocí SIMD
Akcelerace DWT pomocí SIMD
 
Wavelet Lifting on Application Specific Vector Processor
Wavelet Lifting on Application Specific Vector ProcessorWavelet Lifting on Application Specific Vector Processor
Wavelet Lifting on Application Specific Vector Processor
 
GStreamer
GStreamerGStreamer
GStreamer
 
FFmpeg
FFmpegFFmpeg
FFmpeg
 
Wavelets @ CPU
Wavelets @ CPUWavelets @ CPU
Wavelets @ CPU
 

Último

Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfSELF-EXPLANATORY
 
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...Universidade Federal de Sergipe - UFS
 
The dark energy paradox leads to a new structure of spacetime.pptx
The dark energy paradox leads to a new structure of spacetime.pptxThe dark energy paradox leads to a new structure of spacetime.pptx
The dark energy paradox leads to a new structure of spacetime.pptxEran Akiva Sinbar
 
Pests of castor_Binomics_Identification_Dr.UPR.pdf
Pests of castor_Binomics_Identification_Dr.UPR.pdfPests of castor_Binomics_Identification_Dr.UPR.pdf
Pests of castor_Binomics_Identification_Dr.UPR.pdfPirithiRaju
 
User Guide: Magellan MX™ Weather Station
User Guide: Magellan MX™ Weather StationUser Guide: Magellan MX™ Weather Station
User Guide: Magellan MX™ Weather StationColumbia Weather Systems
 
Davis plaque method.pptx recombinant DNA technology
Davis plaque method.pptx recombinant DNA technologyDavis plaque method.pptx recombinant DNA technology
Davis plaque method.pptx recombinant DNA technologycaarthichand2003
 
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuine
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 GenuineCall Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuine
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuinethapagita
 
Speech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxSpeech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxpriyankatabhane
 
Pests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdfPests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdfPirithiRaju
 
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptx
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptxRESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptx
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptxFarihaAbdulRasheed
 
Pests of soyabean_Binomics_IdentificationDr.UPR.pdf
Pests of soyabean_Binomics_IdentificationDr.UPR.pdfPests of soyabean_Binomics_IdentificationDr.UPR.pdf
Pests of soyabean_Binomics_IdentificationDr.UPR.pdfPirithiRaju
 
FREE NURSING BUNDLE FOR NURSES.PDF by na
FREE NURSING BUNDLE FOR NURSES.PDF by naFREE NURSING BUNDLE FOR NURSES.PDF by na
FREE NURSING BUNDLE FOR NURSES.PDF by naJASISJULIANOELYNV
 
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCR
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCRCall Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCR
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCRlizamodels9
 
OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024innovationoecd
 
Fertilization: Sperm and the egg—collectively called the gametes—fuse togethe...
Fertilization: Sperm and the egg—collectively called the gametes—fuse togethe...Fertilization: Sperm and the egg—collectively called the gametes—fuse togethe...
Fertilization: Sperm and the egg—collectively called the gametes—fuse togethe...D. B. S. College Kanpur
 
Four Spheres of the Earth Presentation.ppt
Four Spheres of the Earth Presentation.pptFour Spheres of the Earth Presentation.ppt
Four Spheres of the Earth Presentation.pptJoemSTuliba
 
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubai
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In DubaiDubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubai
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubaikojalkojal131
 
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)Columbia Weather Systems
 
《Queensland毕业文凭-昆士兰大学毕业证成绩单》
《Queensland毕业文凭-昆士兰大学毕业证成绩单》《Queensland毕业文凭-昆士兰大学毕业证成绩单》
《Queensland毕业文凭-昆士兰大学毕业证成绩单》rnrncn29
 

Último (20)

Behavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdfBehavioral Disorder: Schizophrenia & it's Case Study.pdf
Behavioral Disorder: Schizophrenia & it's Case Study.pdf
 
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
REVISTA DE BIOLOGIA E CIÊNCIAS DA TERRA ISSN 1519-5228 - Artigo_Bioterra_V24_...
 
The dark energy paradox leads to a new structure of spacetime.pptx
The dark energy paradox leads to a new structure of spacetime.pptxThe dark energy paradox leads to a new structure of spacetime.pptx
The dark energy paradox leads to a new structure of spacetime.pptx
 
Pests of castor_Binomics_Identification_Dr.UPR.pdf
Pests of castor_Binomics_Identification_Dr.UPR.pdfPests of castor_Binomics_Identification_Dr.UPR.pdf
Pests of castor_Binomics_Identification_Dr.UPR.pdf
 
User Guide: Magellan MX™ Weather Station
User Guide: Magellan MX™ Weather StationUser Guide: Magellan MX™ Weather Station
User Guide: Magellan MX™ Weather Station
 
Davis plaque method.pptx recombinant DNA technology
Davis plaque method.pptx recombinant DNA technologyDavis plaque method.pptx recombinant DNA technology
Davis plaque method.pptx recombinant DNA technology
 
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuine
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 GenuineCall Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuine
Call Girls in Majnu Ka Tilla Delhi 🔝9711014705🔝 Genuine
 
Speech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptxSpeech, hearing, noise, intelligibility.pptx
Speech, hearing, noise, intelligibility.pptx
 
Pests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdfPests of Bengal gram_Identification_Dr.UPR.pdf
Pests of Bengal gram_Identification_Dr.UPR.pdf
 
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptx
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptxRESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptx
RESPIRATORY ADAPTATIONS TO HYPOXIA IN HUMNAS.pptx
 
Pests of soyabean_Binomics_IdentificationDr.UPR.pdf
Pests of soyabean_Binomics_IdentificationDr.UPR.pdfPests of soyabean_Binomics_IdentificationDr.UPR.pdf
Pests of soyabean_Binomics_IdentificationDr.UPR.pdf
 
Hot Sexy call girls in Moti Nagar,🔝 9953056974 🔝 escort Service
Hot Sexy call girls in  Moti Nagar,🔝 9953056974 🔝 escort ServiceHot Sexy call girls in  Moti Nagar,🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Moti Nagar,🔝 9953056974 🔝 escort Service
 
FREE NURSING BUNDLE FOR NURSES.PDF by na
FREE NURSING BUNDLE FOR NURSES.PDF by naFREE NURSING BUNDLE FOR NURSES.PDF by na
FREE NURSING BUNDLE FOR NURSES.PDF by na
 
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCR
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCRCall Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCR
Call Girls In Nihal Vihar Delhi ❤️8860477959 Looking Escorts In 24/7 Delhi NCR
 
OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024OECD bibliometric indicators: Selected highlights, April 2024
OECD bibliometric indicators: Selected highlights, April 2024
 
Fertilization: Sperm and the egg—collectively called the gametes—fuse togethe...
Fertilization: Sperm and the egg—collectively called the gametes—fuse togethe...Fertilization: Sperm and the egg—collectively called the gametes—fuse togethe...
Fertilization: Sperm and the egg—collectively called the gametes—fuse togethe...
 
Four Spheres of the Earth Presentation.ppt
Four Spheres of the Earth Presentation.pptFour Spheres of the Earth Presentation.ppt
Four Spheres of the Earth Presentation.ppt
 
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubai
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In DubaiDubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubai
Dubai Calls Girl Lisa O525547819 Lexi Call Girls In Dubai
 
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
User Guide: Pulsar™ Weather Station (Columbia Weather Systems)
 
《Queensland毕业文凭-昆士兰大学毕业证成绩单》
《Queensland毕业文凭-昆士兰大学毕业证成绩单》《Queensland毕业文凭-昆士兰大学毕业证成绩单》
《Queensland毕业文凭-昆士兰大学毕业证成绩单》
 

Fixed-point arithmetic guide

  • 1. Fixed-point arithmetic David Barina May 23, 2014 David Barina Fixed-point May 23, 2014 1 / 21
  • 2. Integer 1 1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 15 7 8 0 … … 1 1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 −1 7 −8 0 … … David Barina Fixed-point May 23, 2014 2 / 21
  • 3. Floating point a × 2b sign exponent (8 bits) fraction (23 bits) 02331 0 0 1 1 1 1 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 = 0.15625 30 22 (bit index) David Barina Fixed-point May 23, 2014 3 / 21
  • 4. Fixed point 1 1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 −0.0625 7.9375 −8.0000 0.0000 … … 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 1 0 0 0 0 1 1 1 0 0 0 0 15.9375 7.9375 8.0000 0.0000 … … 1 1 1 1 0 0 0 0 1 1 1 1 0 0 0 0 David Barina Fixed-point May 23, 2014 4 / 21
  • 5. Benefits Advantages instructions for the integer arithmetic are sufficient no need for FP instructions (FPU, SSE) constant resolution in the whole range higher accuracy (small dynamic ranges) Drawbacks limited range overflow less accuracy (greater dynamic ranges) David Barina Fixed-point May 23, 2014 5 / 21
  • 6. Notation Qm.n Q3.4 1 sign bit, 3 integer, 4 fractional bits Q1.30 32 bits in total Q15.16 32 bits in total David Barina Fixed-point May 23, 2014 6 / 21
  • 7. Examples type name bits resolution range INT integer 32 1 ±231 ≈ ±2.1 × 109 FP single 32 2−23 ≈ 1.2 × 10−7 ±2128 ≈ ±3.4 × 1038 FX Q15.16 32 2−16 ≈ 1.5 × 10−5 ±215 ≈ ±3.2 × 104 FX Q1.30 32 2−30 ≈ 9.3 × 10−10 ±2 David Barina Fixed-point May 23, 2014 7 / 21
  • 8. Conversion (Qm.n) INT → FX y = x << n; FX → INT k = 1 << (n-1); y = (x + k) >> n; FP → FX #include <math.h> y = round( x * (1 << n) ); FX → FP y = (double)x / (1 << n); David Barina Fixed-point May 23, 2014 8 / 21
  • 9. Rounding (Qm.n) Truncation int floor(int x) { return x & ˜((1<<n)-1); } Ceiling int ceil(int x) { return floor(x + ((1<<n)-1)); } Rounding int round(int x) { return floor(x + (1<<(n-1))); } David Barina Fixed-point May 23, 2014 9 / 21
  • 10. Operations (Qm.n) Zero z = 0; Unit z = 1 << n; One half z = 1 << (n-1); Negation z = -x; Absolute value z = abs(x); David Barina Fixed-point May 23, 2014 10 / 21
  • 11. Operations (Qm.n) Addition z = x + y; Subtraction z = x - y; Multiplication by an integer z = x * i; Multiplication k = 1 << (n-1); z = ( x * y + k ) >> n; Division z = (x << n) / y; David Barina Fixed-point May 23, 2014 11 / 21
  • 12. Multiplication (Q15.16) Multiply a.b × c.d uint32_t result_low = (b * d); uint32_t result_mid = (a * d) + (b * c); uint32_t result_high = (a * c); uint32_t result = (result_high << 16) + result_mid + (result_low >> 16); David Barina Fixed-point May 23, 2014 12 / 21
  • 13. Trick Division by a constant a/b → a × c c = 1/b z = a / 5; // 1/5 = 0.2 = 858993459 in Q31.32 z = (a * 858993459) >> 32; David Barina Fixed-point May 23, 2014 13 / 21
  • 14. Functions Sine by Taylor series [libfixmath] sin(x) = x − x3 3! + x5 5! − x7 !7 + x9 !9 − x11 11! Sine by polynomial [Fixmath] 16 segments, polynomial of degree 4, Remez alg. sin(x) = c0 + c1x1 + c2x2 + c3x3 + c4x4 David Barina Fixed-point May 23, 2014 14 / 21
  • 15. Functions Inverse square root [Fixmath] y = 1/ √ x Newton’s method x → a × 2b y = y (3 − a y2 )/2 Square root [Fixmath] x → a × 2b c = 1/ √ a × a = √ a y ← c × 2b/2 David Barina Fixed-point May 23, 2014 15 / 21
  • 16. Functions Square root [libfixmath] abacus algorithm while (one != 0) { if (x >= y + one) { x = x - (y + one); y = y + 2 * one; } y /= 2; one /= 4; } David Barina Fixed-point May 23, 2014 16 / 21
  • 17. Functions Reciprocal value [Fixmath] y = 1/x Newton’s method x → a × 2b y = y (2 − ay) Division z = x/y =⇒ z = x × (1/y) David Barina Fixed-point May 23, 2014 17 / 21
  • 18. Functions Exponential function [libfixmath] x > 0 =⇒ e−x = 1/ex ex = ∞ n=0 xn n! Natural logarithm [libfixmath] Newton’s method y = y + x − ey ey David Barina Fixed-point May 23, 2014 18 / 21
  • 19. Functions Base-2 logarithm [libfixmath] y = log2(x) |Qm.n y = 0; while( x >= 2 ) { x /= 2; y++; } for_each(n) { x *= x; y *= 2; if( x >= 2 ) { x /= 2; y++; } } David Barina Fixed-point May 23, 2014 19 / 21
  • 20. Functions Base-2 logarithm [Fixmath] y = log2(1 + x) 16 segments, polynomial of degree 4/11, Remez alg. Base-2 exponential [Fixmath] y = 2x 1/32 segments, polynomial of degree 7/3, Remez alg. David Barina Fixed-point May 23, 2014 20 / 21