]> www.ginac.de Git - cln.git/blob - src/real/elem/cl_R_div.cc
df389e0ae98e06da691dd855549910ee743b0bec
[cln.git] / src / real / elem / cl_R_div.cc
1 // binary operator /
2
3 // General includes.
4 #include "cl_sysdep.h"
5
6 // Specification.
7 #include "cl_real.h"
8
9
10 // Implementation.
11
12 #include "cl_R.h"
13 #include "cl_rational.h"
14 #include "cl_RA.h"
15 #include "cl_integer.h"
16 #include "cl_I.h"
17 #include "cl_F.h"
18 #include "cl_sfloat.h"
19 #include "cl_SF.h"
20 #include "cl_ffloat.h"
21 #include "cl_FF.h"
22 #include "cl_dfloat.h"
23 #include "cl_DF.h"
24 #include "cl_lfloat.h"
25 #include "cl_LF.h"
26 #include "cl_N.h"
27
28 ALL_cl_LF_OPERATIONS_SAME_PRECISION()
29
30 const cl_R operator/ (const cl_R& x, const cl_R& y)
31 {
32         if (eq(x,0))
33                 // 0 / y = exakte 0, außer wenn y=0
34                 { if (zerop(y))
35                         { cl_error_division_by_0(); }
36                   else
37                         return 0;
38                 }
39         else
40 #define div(a,b) a/b
41         realcase6(x
42         , /* I */       
43                         realcase6(y
44                         , /* I */       return div(x,y);
45                         , /* RT */      return div(x,y);
46                         , /* SF */      return div(cl_I_to_SF(x),y);
47                         , /* FF */      return div(cl_I_to_FF(x),y);
48                         , /* DF */      return div(cl_I_to_DF(x),y);
49                         , /* LF */      return div(cl_I_to_LF(x,LFlen0(y)),y); // cf. cl_I_LF_div
50                         );
51         , /* RT */      
52                         realcase6(y
53                         , /* I */       return div(x,y);
54                         , /* RT */      return div(x,y);
55                         , /* SF */      return div(cl_RA_to_SF(x),y);
56                         , /* FF */      return div(cl_RA_to_FF(x),y);
57                         , /* DF */      return div(cl_RA_to_DF(x),y);
58                         , /* LF */      return cl_RA_LF_div(x,y);
59                         );
60         , /* SF */      
61                         realcase6(y
62                         , /* I */       return div(x,cl_I_to_SF(y));
63                         , /* RT */      return div(x,cl_RA_to_SF(y));
64                         , /* SF */      return div(x,y);
65                         , /* FF */      return cl_FF_to_SF(div(cl_SF_to_FF(x),y));
66                         , /* DF */      return cl_DF_to_SF(div(cl_SF_to_DF(x),y));
67                         , /* LF */      return cl_LF_to_SF(div(cl_SF_to_LF(x,LFlen0(y)),y));
68                         );
69         , /* FF */      
70                         realcase6(y
71                         , /* I */       return div(x,cl_I_to_FF(y));
72                         , /* RT */      return div(x,cl_RA_to_FF(y));
73                         , /* SF */      return cl_FF_to_SF(div(x,cl_SF_to_FF(y)));
74                         , /* FF */      return div(x,y);
75                         , /* DF */      return cl_DF_to_FF(div(cl_FF_to_DF(x),y));
76                         , /* LF */      return cl_LF_to_FF(div(cl_FF_to_LF(x,LFlen0(y)),y));
77                         );
78         , /* DF */      
79                         realcase6(y
80                         , /* I */       return div(x,cl_I_to_DF(y));
81                         , /* RT */      return div(x,cl_RA_to_DF(y));
82                         , /* SF */      return cl_DF_to_SF(div(x,cl_SF_to_DF(y)));
83                         , /* FF */      return cl_DF_to_FF(div(x,cl_FF_to_DF(y)));
84                         , /* DF */      return div(x,y);
85                         , /* LF */      return cl_LF_to_DF(div(cl_DF_to_LF(x,LFlen0(y)),y));
86                         );
87         , /* LF */      
88                         realcase6(y
89                         , /* I */       return cl_LF_I_div(x,y);
90                         , /* RT */      return cl_LF_RA_div(x,y);
91                         , /* SF */      return cl_LF_to_SF(div(x,cl_SF_to_LF(y,LFlen0(x))));
92                         , /* FF */      return cl_LF_to_FF(div(x,cl_FF_to_LF(y,LFlen0(x))));
93                         , /* DF */      return cl_LF_to_DF(div(x,cl_DF_to_LF(y,LFlen0(x))));
94                         , /* LF */      return div(x,y);
95                         );
96         );
97 }