]> www.ginac.de Git - cln.git/blob - src/float/lfloat/elem/cl_I_LF_div.cc
Initial revision
[cln.git] / src / float / lfloat / elem / cl_I_LF_div.cc
1 // cl_I_LF_div().
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_LF.h"
8
9
10 // Implementation.
11
12 #include "cl_lfloat.h"
13 #include "cl_LF_impl.h"
14 #include "cl_integer.h"
15 #include "cl_I.h"
16 #include "cl_DS.h"
17 #include "cl_F.h"
18 #include "cl_N.h"
19
20 const cl_R cl_I_LF_div (const cl_I& x, const cl_LF& y)
21 {
22 // Method:
23 // If x=0, return 0.
24 // Else convert x to a float and divide.
25 // (If x is shorter than y, we would gain nothing by dividing the absolute
26 // value of x by the mantissa of y, since the numerator of the division would
27 // have to have 2*length(y)+1 words, even if length(x) is much smaller than
28 // length(y).)
29         if (eq(x,0)) { return 0; }
30         var uintC len = TheLfloat(y)->len;
31         return cl_I_to_LF(x,len) / y;
32 }
33 // Bit complexity (N = max(length(x),length(y))): O(M(N)).