 Open Access
 Authors : M.A. SandovalHernandez, G.C. VelezLopez, H. VazquezLeal , U.A. FilobelloNino, G. J. MoralesAlarcon, E. DeLeoBaquero, A.C. BielmaPerez , C.E SampieriGonzalez, J.E. PerezJacome Friscione, A.D. ContrerasHernandez , O. AlvarezGasca, J. SanchezOrea, L. CuellarHernandez
 Paper ID : IJERTV12IS010134
 Volume & Issue : Volume 12, Issue 01 (January 2023)
 Published (First Online): 08022023
 ISSN (Online) : 22780181
 Publisher Name : IJERT
 License: This work is licensed under a Creative Commons Attribution 4.0 International License
Basic Implementation of FixedPoint Arithmetic in Numerical Analysis

SandovalHernÃ¡ndez1, G.C. VelezLÃ³pez2, H. VÃ¡zquezLeal3,4,*, U.A. FilobelloNino3, G. J. MoralesAlarcÃ³n5,

DeLeoBaquero1, A.C. BielmaPÃ©rez1, C.E SampieriGonzÃ¡lez3, J.E. PÃ©rezJÃ¡come Friscione3, A.D. Contreras HernÃ¡ndez3, O. ÃlvarezGasca3, J. SÃ¡nchezOrea3, L. CuellarHernÃ¡ndez3.
1 Centro de Bachillerato TecnolÃ³gico Industrial y de Servicios No. 190, Av. 15 Col. Venustiano Carranza 2da SecciÃ³n, Boca del RÃo, 94297, Veracruz, MÃ©xico.
2Instituto Nacional de AstrofÃsica, Ã“ptica y ElectrÃ³nica, Luis Enrique Erro 1, Sta. MarÃa Tonantzintla, 72840, Puebla, MÃ©xico.
3Facultad de InstrumentaciÃ³n ElectrÃ³nica, Universidad Veracruzana, Circuito Gonzalo Aguirre BeltrÃ¡n S/N, Xalapa, 91000, Veracruz, MÃ©xico.
4Consejo Veracruzano de InvestigaciÃ³n CientÃfica y Desarrollo TecnolÃ³gico, Av. Rafael Murillo Vidal No. 1735, CuauhtÃ©moc, Xalapa, 91069, Veracruz, MÃ©xico.
5 Instituto de PsicologÃa y EducaciÃ³n, Universidad Veracruzana, AgustÃn Melgar 2, Col. 21 de Marzo, Xalapa, 91010 Veracruz, MÃ©xico.
Abstract In this paper, we present a teaching aid for the implementation of fixedpoint arithmetic in numerical analysis algorithms using the C/C++ programming language. Through the examination of four case studies, including the solution of a system of equations through LU factorization, determination of the definite integral through numerical integration, determination of a root through the NewtonRaphson method, and the evaluation of a polynomial of order 9, we demonstrate the advantage of fixed point arithmetic in reducing computation times when dealing with complex numerical calculations. In particular, the case study utilizing the NewtonRaphson method illustrates the potential for a significant reduction in computation time of more than 100 times in comparison to the use of floating point arithmetic. This makes the implementation of these algorithms in embedded systems, where a math coprocessor is not present a viable option.
Keywords Fixedpoint, computing time, float point, numerical analysis, C language.

INTRODUCTION
In fixedpoint arithmetic, operations such as division and multiplication are carry out with bit shifts and are treated as any normal signed or unsigned integer. This arithmetic is very important when there is no math coprocessor. For example, pic microcontrollers do not have the necessary hardware to handle fixedpoint arithmetic. The advantage is the speed that is obtained when handling data in this format, however accuracy is lost [1].
Fixedpoint arithmetic (FP) is used in applications that do not require or cannot have a floatingpoint arithmetic unit [2]. The floating point arithmetic system has disadvantages because the operations require higher energy consumption but with lower speed of operation compared to the arithmetic fixed point [3]. Small processors and low cost embedded systems they do not have a unit for handling floating point [4].
For example Fixed point arithmetic it is widely used in Digital Signal Processing (DSP) [5]. Fixedpoint arithmetics can be carried out using the hardware built for integer arithmetic. In [6] a divisionfree algorithm was presented for exponential function using NewtonRaphson improving
computational speed. In [7] the fixed point calculation is presented to evaluate logarithms, it introduces variants of the logarithm that inputs a floating point number and outputs the fixed point result. In [8] a method for the rapid division of integers in software was presented, for its implementation in processors with an integrated hardware multiplier. It is based on determining the reciprocal of the divisor with Newton Raphson, with 16 fixedpoint bits. In [9] the architecture of a fixedpoint arithmetic unit based on the use of integer arithmetic operations in a fieldprogrammable gate array (FPGA) was proposed. Likewise, [10] presents the user guide for a package for fixedpoint arithmetic implemented in VHDL (Very High Speed Integrated Circuit).
This paper is organized as follows. In Section II, we introduce the basics fixedpoint concept. Implementations of four case studies are presented. In section III presents four case studies where a fixed point is applied; the first one, decomposition to solve a system of 6×6 simultaneous equations; the second one, determination of a definite integral using Simpson's rule; the third one, the implementation for NewtonRaphson; and finally, the fourth one, the evaluation of a polynomial. The discussion is presented in section IV. Finally, a concluding remark is given in Section V.

SOME BASICS FIXEDPOINT
In the implementation of fixedpoint arithmetic, fixed numbers are treated as integers, but the programmer must keep in mind that root point tracking must be carry out during each
operation [11,12,13]. Figure 1 shows the point radix for = 8
bit with 3.4 format. It has 3 bits for integer part and 4 bits for
fractional part and 1 bit for sign.
Figure 1. Fixed point representation for 3,4.
In fixed point operations, the following aspects have to be considered

The number has a sign or unsigned.

The position of the radix point in signed numbers in relation to sign bit. For unsigned numbers, the position of the radix point relative to the most significant bit. The bits of numbers of the fractional part to be stored.


APPLICATION OF FIXED POINT

Case study 1: LU Decomposition to solve a system of 6×6 simultaneous equations.
In this case study we will solve a system 6×6 of linear equations through the LU factorization [16,17], given for (5)
The notation is used to represent fixed point numbers that
5 1 1
2 5 2
1 3
are given as . where m bits for the integer part bits for
the fractional part. Total number of bits = + + 1 for
1 4 6
2 4 3 2
3
signed numbers.
To obtain the value of bit number in . format, it
1 2 2
1 1 2
2 3 1
1 4 3
3 9
4 = 10
can be calculated by
2
2 3 1
[4 5 35 3 5 5
5 3 3] [6]
2
[ 6 ](2)
value = 12 + 2
=0
(1)
The implementation of (5) in fixed point is given
//////////// Fixed point printf( );
Arithmetic operations we considered 1 and 1 as the integer parts of the first number and 2 and 2 the integer parts of the
second one. In addition and subtraction require that the numbers
are aligned, the same numbers of bits in the integer part and in the fractional part.
In the multiplication of two numbers, one with bits, and another with bits, we obtain a number of + . Also the
size of the integer and fractional parts are the sum of the integer
and fractional parts of both numbers. i.e. 1 + 2 and 1 + 2
respectively [13].
In the case of division, the results can be reduced to following cases.

The quotient of dividing two unsigned fixed point
number is given by a number with an integer part 1 + 2
and a fractional part 1 + 2.

The quotient of dividing a number with sign and other
unsigned, we obtain a number with an integer part 1 + 2
and a fractional part 1 2 .

The quotient of dividing two signed numbers gives a
numbers with an integer part 1 + 2 + 1 and a fractional
auto start = std::chrono::steady_clock::now();
for(h=0;h<1000;h++)
{
for(i=0;i<n;i++) for(j=0;j<n;j++)
if(i>j)
{
u[i][j]=floatfix(0); u_f[i][j]=floatflo(u[i][j]);
}
else if(i==j)
{
l[i][j]=floatfix(1); l_f[i][j]=floatflo(l[i][j]);
}
else
{
l[i][j]=floatfix(0); l_f[i][j]=floatflo(l[i][j]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
sum=floatfix(0);
if(i<=j)
{
for(k=0;k<n;k++)
{
part 1 2.
We must be careful when obtaining 2 > 1, which leads to a
negative fractional part. To avoid this, the dividend can be
shifted to the left. In this way, we can have available at least as many fractional bits as the divisor. This leads to the next rule:
if 2 > 1 then convert divisor to 1, , where 2 [11, 12,
}
else
{
if(k!=i)
sum=sum+FMUL(l[i][k], u[k][j]);
u[i][j]=a[i][j]sum;
u_f[i][j]=floatflo(u[i][j]);
}
13]. To convert from floatingpoint to fixed point we follow these steps

Multiply the floating point number by 2 raised to the
number of desired fractional bits.

Round the number to the nearest whole number.
for(k=0;k<n;k++)
{
if(k!=j)
sum=sum+FMUL(l[i][k], u[k][j]);
[i][j]=FDIV((a[i][j]sum),u[j][j]); l_f[i][j]=floatflo(l[i][j]);}

If the number is negative take twos complement of the }
value arrived at step 2. Store the rounded x in an integer }
container. }
In practice fixed point is programmed in some programming languages such as C, C++ [14]. This is usually done through macros that are defined at the begin of the program [14], [15].
In the appendix is presented the code in Maple that shows the use of (1) to understand how fixedpoint arithmetic is implemented.
y[0]=FDIV(b[0],l[0][0]);
y_f[0]=floatflo(y[0]);
for(i=1;i<n;i++)
{
sum=floatfix(0);
for(j=0;j<i;j++)
{
sum=sum+FMUL(y[j],l[i][j]);
}
y[i]=b[i]sum;
y_f[i]=floatflo(y[i]);
}
x[n1] = (y[n1]);
x[n1] = FDIV((x[n1]), (u[n1][n1]));
x_f[n1]=floatflo(x[n1]);
for(i=n2;i>=0;i–)
{
sum=floatfix(0);
for(j=n1;j>i;j–)
sum = sum + FMUL(x[j],u[i][j]);
x[i] = (y[i]sum);
x[i] = FDIV((x[i]),u[i][i]);
x_f[i]=floatflo(x[i]);
}
}
auto end = chrono::steady_clock::now();
printf("The solution are:\n "); printf("Y X \n"); for(i=0;i<n;i++)
{
printf("%5.6f\t %5.6f\t\n",y_f[i],x_f[i]);
}
auto elapsed = chrono::duration_cast<chrono::microseconds>(end – start); cout << "Chrono time " << elapsed.count() << "us." <<endl;



Case study 2: Determine the definite integral with Simpsons Rule 1/3.
In this case study we will calculate the numerical integral by means of Simpson's Rule 1/3 [16,17] for the function given by
() = 6.03332 + 2.0333.
(3)
The fixedpoint implementation for (3) is given for
//Coeficients const1_fix=floatfix(6.0333); const2_fix=floatfix(2.0333);
// function (3)
f_fix = FMUL(FMUL(X, X),const1_fix)+ const2_fix

Case study 3: Determine the numerical root with Newton Raphson
In the first case we will implemented fixed point to determine the roots of the function using NewtonRaphson [16,17].
() = 0.32225 1.6786623 1.559448.
(4)
The fixedpoint implementation for (2) and its derivative are given by
//constants const1=floatfix(0.3222); const2=floatfix(1.678662); const3=floatfix(1.559448); const4=floatfix(1.6110); const5=floatfix(5.035986);
/* Defining equation (2)
f0_fix= FMUL(FMUL(FMUL(FMUL(FMUL(X,X), X),X),X),const1) –
FMUL(FMUL(FMUL(X,X), X),const2) +FMUL(X,const3);
/* Derivative of (2) = 1.61104 + 5.0359862 1.559448 */ fd_fix= FMUL(FMUL(FMUL(FMUL(X,X), X),X),const4) –
FMUL(FMUL(X,X),const5) +const3;

Case study 4: Polynomial evaluation.
In this case study we are going to evaluate the function
given by (4) in the interval 0 1 which was obtained in [18].
() = 3.173281398136 1.702 1.7981927922783
0.9448762678334 + 0.3174066672115
+ 1.0812386179316 + 0.8471278415547
0.0833710543388 7.859.
(5)
The implementation in fixed point for (4) is
// Constants const1_fix=floatfix(3.173281398136); const2_fix=floatfix(1.70); const3_fix=floatfix(1.798192792278); const4_fix=floatfix(0.944876267833); const5_fix=floatfix(0.317406667211); const6_fix=floatfix(1.081238617931); const7_fix=floatfix(0.847127841554); const8_fix=floatfix(0.083371054338); const9_fix=floatfix(7.85);
// Equation (4) y_fix=FMUL(const1_fix,x_fix)
FMUL(FMUL(const2_fix,x_fix),x_fix) –
FMUL(FMUL(FMUL(const2_fix,x_fix),x_fix),x_fix) – FMUL(FMUL(FMUL(FMUL(const4_fix,x_fix),x_fix),x_fix),x_fix) + FMUL(
FMUL(FMUL(FMUL(FMUL(const5_fix,x_fix),x_fix),x_fix),x_fix), x_fix) + FMUL(FMUL(
FMUL(FMUL(FMUL(FMUL(const6_fix,x_fix),x_fix),x_fix),x_fix), x_fix),x_fix)+ FMUL(FMUL(FMUL(
FMUL(FMUL(FMUL(FMUL(const7_fix,x_fix),x_fix),x_fix),x_fix), x_fix),x_fix),x_fix) – FMUL(FMUL(FMUL(FMUL( FMUL(FMUL(FMUL(FMUL(const8_fix,x_fix),x_fix),x_fix),x_fix), x_fix),x_fix),x_fix),x_fix) FMUL(FMUL(FMUL(FMUL( FMUL(FMUL(FMUL(FMUL(const9_fix,x_fix),x_fix),x_fix),x_fix), x_fix),x_fix),x_fix),x_fix);


DISCUSION
The computer used for the simulations was an Intel Core Pentium(R) IntelÂ® Core i77700 CPU @ running at 3.60GHz
Ã— 8 under Linux Ubuntu 18.04.6 LTS, using as compiler the gcc
7.5.0 with level 3 of optimization. In all case studies, the chrono library of the C++ language was used to compare computing times in floating point and fixed point implementations. The macros used in the executed routines of all the study cases [15] are
#define FMUL(a,b) (((a)*(b))>>(FIXED_FRACBITS))
#define FDIV(a,b) (((a)<<(FIXED_FRACBITS))/(b))
In the appendix, the complete code in C++ for case study 3 is presented. In this code, the macros that are used for different operations with fixedpoint arithmetic have been implemented. In the first case study, we propose to solve a system of six linear equations with six unknowns using the LU factorization method. Table I presents a comparison of the solution obtained from this system using floating point and fixed point representations. It is observed that the computing time for the floating point representation is shorter when compared to the
fixed point representation.
Exact
FP
1
4.131182
4.261719
2
19.395699
19.867188
TABLE I. COMPARATIVE ANALYSIS OF COMPUTATION TIMES FOR CASE STUDY 1
3
13.305374
13.660156
4
11.965590
12.312500
5
8.266665
8.496094
6
0.081719
0.125000
Time
0.99s
72.227s
In the second case study, the definite integral of a quadratic function of the second degree (3) with float point coefficients was calculated using the Simpson 1/3 method. The function was implemented in a floating point format and a total of 1,000,000 iterations were conducted in the study.
Table II displays the computation times obtained in the second case study. It can be observed that the computation time using the fixedpoint format is shorter than the floatingpoint format. However, it should be noted that an absolute error of 0.124 was present in the fixedpoint implementation.
TABLE II. COMPARATIVE ANALYSIS OF COMPUTATION TIMES FOR CASE STUDY 2.
Area
Area in FP
Time s
Numerical
4.044
–
87
Fixed point
3.851562
986
54
In the third case study, the NewtonRaphson algorithm was utilized to obtain the root of the function (4), see that the function used is of degree 5. The root was calculated by implementing the algorithm in both floating point and fixed point formats. The number of iterations required to obtain the root was found to be 9 in both implementations. An initial value
of = 6 was utilized, with an acceptable error tolerance of 0.1.
A total of 100,000 iterations were conducted in the study.
Table III presents the results obtained from the root calculations using both implementations of the Newton Raphson algorithm. It can be observed that an error tolerance of approximately 0.01 was achieved for both implementations. Additionally, it is evident that the computation time for the fixedpoint implementation was significantly less than that of the floatingpoint implementation.
TABLE III. COMPARATIVE ANALYSIS OF COMPUTATION TIMES FOR CASE STUDY 3.
Steps
Root
Root in FP
Time s
Numerical
9
2.003563
–
17192
Fixed point
9
2.013672
1031
136
The fourth case study evaluated a function of degree nine,
as previously published in [18], within the interval 0 1
with increments of 0.01. The procedure was conducted 1000
times and the results indicate that the computation time in floatingpoint format was 41 milliseconds, while it was significantly shorter at 1 millisecond using the fixedpoint format. Table IV presents a selection of y values obtained with
increments of = 0.05 to demonstrate the accuracy achieved
with the floatpoint implementation.
Value
Value
Value obtained
with FP
0
0
0
0.05
0.153556
0.15332
0.1
0.297191
0.296387
0.15
0.429377
0.429199
TABLE IV. COMPARATIVE ANALYSIS OF COMPUTATION TIMES FOR CASE STUDY 4.
Figure 2 illustrates the absolute error present when utilizing
0.2
0.548501
0.547852
0.25
0.652919
0.652344
0.3
0.741019
0.742188
0.35
0.811315
0.813477
0.4
0.86254
0.867676
0.45
0.8937565
0.900391
0.5
0.904447
0.914062
0.55
0.894607
0.908203
0.6
0.864772
0.881348
0.65
0.815991
0.835938
0.7
0.749705
0.77002
0.75
0.667469
0.690918
0.8
0.570507
0.597168
0.85
0.459009
0.487305
0.9
0.331136
0.369629
0.95
0.181636
0.241699
1
4.84E07
0.103027
the Fixed Point Implementation within the interval 0 1. It is observed that the absolute error increases as the value of
approaches 1. This phenomenon is attributed to the increase in
numerical values of , which in turn leads to an increase in the
numerical values generated in each of the terms in (9) as a result
of the multiplications of each coefficient with the
corresponding power of . Furthermore, the computation accuracy diminishes as the error is a function of the number of
bits used to represent the information. To mitigate numerical errors, an increase in the number of bits in the fractional part would be necessary.
Figure 2. Absolut error for case study IV.
In the present study, the performance of fixed point and floating point implementations were compared across multiple case studies. It is worth noting that the computer utilized in these experiments was equipped with a mathematical coprocessor capable of performing floating point operations. The results indicate that in situations where the number of float point arithmetic operations is relatively low, the floatpoint implementation tends to exhibit superior performance as demonstrated in Table I of the first case study, where operations such as multiplication, division, addition, and subtraction were performed. However, as the complexity of the arithmetic calculations increases, the computing times in floatpoint operations also increase. This phenomenon is observed in case study 2, as presented in Table II. Specifically, in this case the expression being evaluated was a second degree function with
constant coefficients. It is important to note that the use of fixedpoint arithmetic in this scenario resulted in a reduction of computation time, as well as an acceptable error level.
In the third case study, a fifthdegree function was evaluated using the NewtonRaphson method to determine one of its roots. The results indicate that the computation time using a fixed point was significantly lower compared to the use of floating point. This trend continues in the fourth case study, where a polynomial of a different degree was evaluated, with a notable reduction in computation time when using a fixed point approach. However, it is important to note that in all of the case studies, an error was observed in the implementation of fixed point algorithms. This highlights the need for careful consideration and implementation in order to effectively use fixed point in numerical analysis. Additionally, it is important to note that the use of fixed point may not always be the most appropriate method and that other techniques, such as floating point, should also be considered in the analysis.
However, it is important to note that in all the case studies presented in this article, an error occurred when implementing a fixed point. Despite this, the results of the case studies show that the use of fixed point can provide significant performance gains in certain situations. As such, it is crucial to carefully evaluate the tradeoffs between computation time and numerical accuracy when deciding to implement fixed point in numerical analysis algorithms. The results obtained show a reduction in computation times, for which fixedpoint arithmetic is useful and applicable to embedded systems, especially those that lack a mathematical processor. Furthermore, the article presented a teaching aid for the implementation of fixed point in numerical analysis algorithms such as the NewtonRaphson method, where a speed increase of more than 100 times was achieved compared to that obtained with floatpoint. In this work the computing times were measured using the C language, however it is possible to measure computing time using Fortran [1922].

CONCLUDING REMARKS


In this study, the impleentation of fixed point arithmetic in four numerical analysis algorithms was presented: the solution of a system of equations through LU factorization, the determination of a definite integral through numerical integration, the determination of a root through the Newton Raphson method, and the evaluation of a ninthorder polynomial. The results of these case studies demonstrate the advantages of fixed point implementation in terms of computation time when dealing with complex numerical calculations. The aim of this article is to provide readers with a clear understanding of fixed point implementation through simple and reproducible examples. As a future research direction, it would be beneficial to implement these algorithms on embedded systems, such as PIC microcontrollers, to further evaluate the advantages of fixed point implementation in real world applications.
DECLARATION OF INTERESTS STATEMENT
The authors declare that there are no conflicts of interest regarding the publication of this paper.
ACKNOWLEDGMENTS
Authors would like to thank Roberto Ruiz Gomez for his contribution to this project. The authors are grateful to the anonymous referee for a careful checking of details and helpful comments that improved this paper.
APPENDIX

Code 1. Program in Maple
#Code written by the authors
#Code Maple for understand Fixed Point
#The follow code presents a method for understanding fixed point numbers in Qm.n
restart;
#Let Q(1, 6);
Digits:=9;
#implementation of formula 1, see text. Q1,6;
V := b[N1]*2^m+sum(b[i]*2^(in), i = 0 .. N2);
#NN := m+n+1; NN := 1+6+1;
# Example 1
value := expand(subs(N = 8, m = 1, n = 6, V)); b[7] := 0;
b[6] := 1;
b[5] := 1;
b[4] := 0;
b[3] := 1;
b[2] := 0;
b[1] := 1;
b[0] := 1;
evalf(value);
##################################
#Let Q(1, 6)
#Example 2
value := expand(subs(N = 8, m = 3, n = 4, V)); b[7] := 0;
b[6] := 1;
b[5] := 1;
b[4] := 0;
b[3] := 1;
b[2] := 0;
b[1] := 1;
b[0] := 1;
evalf(value);

Code 2. Program in C++
/*Complete code for the implementation in fixedpoint for the study case number 3*/
//Libraries
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<chrono>
#include<unistd.h>
using namespace std;
//******* Macros FIXEDPOINT ****************//
//////// Fractional bits
#define FIXED_FRACBITS 11
typedef int fixedp;
// Convert to fixed point
#define shortfix(x) ((fixedp)((x) << (FIXED_FRACBITS)))
#define intfix(x) ((fixedp)((x) << (FIXED_FRACBITS)))
#define longfix(x) ((fixedp)((x) << (FIXED_FRACBITS)))
#define floatfix(x) ((fixedp)((x) * (1 << (FIXED_FRACBITS))))
#define doublefix(x) ((fixedp)((x) * (1 << (FIXED_FRACBITS))))
//// Convert to floating point /////////////
#define shortflo(x) ((short)((x) >> (FIXED_FRACBITS)))
#define intflo(x) ((int)((x) >> (FIXED_FRACBITS)))
#define longflo(x) ((long)((x) >> (FIXED_FRACBITS)))
#define floatflo(x) ((float)(x) / (1 << (FIXED_FRACBITS)))
#define doubleflo(x) ((double)(x) / (1 << (FIXED_FRACBITS)))
////////// Another option /////////////////////////
/* Basic operations between two numbers a and b at a fixed point in q format returning in q format q */
#define FADD(a,b) ((a)+(b))
#define FSUB(a,b) ((a)(b))
#define FMUL(a,b) (((a)*(b))>>(FIXED_FRACBITS))
#define FDIV(a,b) (((a)<<(FIXED_FRACBITS))/(b))
// Variables into fixedpoint
fixedp x_fix, y_fix, const1_fix, const2_fix, const3_fix, const4_fix,const5_fix,const6_fix,const7_fix,const8_fix,cons t9_fix,const10_fix,const11_fix;
int main(void)
{
float x=0,y=0; int contador; x_fix=floatfix(x); y_fix=floatfix(y);
const1_fix=floatfix(3.173281398136); const2_fix=floatfix(1.70); const3_fix=floatfix(1.798192792278); const4_fix=floatfix(0.944876267833); const5_fix=floatfix(0.317406667211); const6_fix=floatfix(1.081238617931); const7_fix=floatfix(0.847127841554); const8_fix=floatfix(0.083371054338); const9_fix=floatfix(7.85); const10_fix=floatfix(1.0); const11_fix=floatfix(0.01);
// Clock
auto start = chrono::steady_clock::now();
for(contador=1;contador<1000;contador++)
{
for(x_fix=0; x_fix<=const10_fix;
x_fix=x_fix+const11_fix)
{
y_fix= FMUL(const1_fix,x_fix) FMUL(FMUL(const2_fix,x_fix),x_fix) – FMUL(FMUL(FMUL(const2_fix,x_fix),x_fix),x_fix) – FMUL(FMUL(FMUL(FMUL(const4_fix,x_fix),x_fix),x_fix),x_fix)
+ FMUL(
FMUL(FMUL(FMUL(FMUL(const5_fix,x_fix),x_fix),x_fix),x_fix), x_fix) + FMUL(FMUL(
FMUL(FMUL(FMUL(FMUL(const6_fix,x_fix),x_fix),x_fix),x_fix), x_fix),x_fix)+ FMUL(FMUL(FMUL( FMUL(FMUL(FMUL(FMUL(const7_fix,x_fix),x_fix),x_fix),x_fix), x_fix),x_fix),x_fix) – FMUL(FMUL(FMUL(FMUL( FMUL(FMUL(FMUL(FMUL(const8_fix,x_fix),x_fix),x_fix),x_fix), x_fix),x_fix),x_fix),x_fix) FMUL(FMUL(FMUL(FMUL( FMUL(FMUL(FMUL(FMUL(const9_fix,x_fix),x_fix),x_fix),x_fix), x_fix),x_fix),x_fix),x_fix);
}
}
auto end = chrono::steady_clock::now(); cout << "Elapsed time in ms: "<<
chrono::duration_cast<chrono::milliseconds>(end
start).count() << " ms"<< endl;
cout << "el valor usando PFIJO es"<<floatflo(y_fix)
<<endl;
return 0;
}
REFERENCES
[1] Kraeling, Mark B. "Fixedpoint math in timecritical C applications." Wescon/96. IEEE, 587593,1996. [2] Anton Cervin, Fix Point Implementation of Control Algorithms, Lund University. A Graduate Course on Embedded Control Systems Pisa 8 12 June 2009. [3] O. SchlÃ¶sser, "Implementing a C++ FixedPoint Class for Embedded Systems." 3, 2013. [4] Ramanathan, S., et al. "Design and implementation of fixed point arithmetic unit." Int. J. Eng. Res. Appl. 6.6 (2016): 1113. [5] Roman, Kuc. "Introduction to Digital Signal Processing." (1982). [6] Chang, ChungHsien, et al. "A divisionfree algorithm for fixedpoint power exponential function in embedded system." 2013 1st International Conference on Orange Technologies (ICOT). IEEE, 223226, 2013. [7] J. Le Maire, N. Brunie, F. de Dinechin, J. M. Muller, "Computing floatingpoint logarithms with fixedpoint operations." 2016 IEEE 23nd Symposium on Computer Arithmetic (ARITH). IEEE, 2016. [8] Nikola M. Nenadic, and Svetlana B. Mladenovic. "Fast division on fixed point DSP processors using NewtonRaphson method." EUROCON 2005The International Conference on" Computer as a Tool". Vol. 1. IEEE, 2005. [9] Przyby, Andrzej. "Fixedpoint arithmetic unit with a scaling mechanism for FPGAbased embedded systems." Electronics 10.10 1164.(2021): [10] Bishop, David. "Fixed point package users guide." Packages and bodies for the IEEE (2006): 10762008. [11] Oberstar, Erick L, Fixedpoint representation & fractional math, Oberstar Consulting, vol. 9 pp. 19, 2007. [12] Yates, Randy, Fixedpoint arithmetic: An introduction, Digital Signal Labs, vol. 81, no. 83, pp. 15, 2009. [13] Pyeatt, Larry and Ughetta, William, ARM 64Bit Assembly Language, Newnes, 2019. [14] H. Shildt, Turbo c/c++ 3.1 Manual de referencia 1ed Mcgraw Hill, 1994. [15] Application Note 33, Fixed Point Arithmetic on the ARM, document number: ARM DAI 0033A, September 1996, https://developer.arm.com/documentation/dai0033/a/ [16] Burden, Richard L., J. Douglas Faires, and Annette M. Burden. Numerical analysis. Cengage learning, 2015. [17] Chapra, Steven C., et al. MÃ©todos numÃ©ricos para ingenieros. McGraw Hill, 2011. [18] H. VazquezLeal, M.A. SandovlHernandez, U. A. FilobelloNino, J. HuertaChua. "The novel Lealpolynomials for the multiexpansive approximation of nonlinear differential equations." Heliyon, 2020. [19] M. SandovalHernandez, H. VazquezLeal, U. FilobelloNino, Elisa De LeoBaquero, Alexis C. BielmaPerez, J.C. VichiMendoza, O. Alvarez Gasca, A.D. ContrerasHernandez, N. BagatellaFlores, B.E. Palma Grayeb, J. SanchezOrea, L. CuellarHernandez. The Quadratic Equation and its Numerical Roots." International Journal of Engineering Research y Technology 10.6 (2021), 301305. 2021. [20] M. A. SandovalHernÃ¡ndez, H. VÃ¡zquezLeal, J. HuertaChua, F. J. CastroGonzÃ¡lez, U. A. FilobelloNino. "DidÃ¡ctica del graficado de funciones: el caso de las funciones piecewise." RIDE. Revista Iberoamericana para la InvestigaciÃ³n y el Desarrollo Educativo 12.24 (2022). [21] H. VazquezLeal, Hector, M. A. SandovalHernandez, and U. Filobello Nino. "The novel family of transcendental Lealfunctions with applications to science and engineering." Heliyon 6.11 (2020). [22] T. Fukushima, "Precise and fast computation of Lambert Wfunctions without transcendental function evaluations." Journal of Computational and Applied Mathematics 244 (2013), 7789, 2013.