/cln-1.3.2/src/float/lfloat/elem/cl_LF_RA_div.cc
C++ | 33 lines | 19 code | 8 blank | 6 comment | 2 complexity | 14e8c7b3228d54e04faafc39443d5d57 MD5 | raw file
Possible License(s): GPL-2.0
1// cl_LF_RA_div().
2
3// General includes.
4#include "base/cl_sysdep.h"
5
6// Specification.
7#include "float/lfloat/cl_LF.h"
8
9
10// Implementation.
11
12#include "cln/lfloat.h"
13#include "cln/rational.h"
14#include "rational/cl_RA.h"
15
16namespace cln {
17
18const cl_LF cl_LF_RA_div (const cl_LF& x, const cl_RA& y)
19{
20// Method:
21// Write y = u/v. Return (x*v)/u.
22 if (integerp(y)) {
23 DeclareType(cl_I,y);
24 return cl_LF_I_div(x,y);
25 } else {
26 DeclareType(cl_RT,y);
27 var const cl_I& u = TheRatio(y)->numerator; // u /= 0
28 var const cl_I& v = TheRatio(y)->denominator; // v /= 0
29 return cl_LF_I_div(The(cl_LF)(cl_LF_I_mul(x,v)),u);
30 }
31}
32
33} // namespace cln