]> www.ginac.de Git - cln.git/blob - src/real/elem/cl_R_div.cc
Remove exception hooks in favor of real C++ exceptions:
[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 "cln/real.h"
8
9
10 // Implementation.
11
12 #include "cl_R.h"
13 #include "cln/rational.h"
14 #include "cl_RA.h"
15 #include "cln/integer.h"
16 #include "cl_I.h"
17 #include "cl_F.h"
18 #include "cln/sfloat.h"
19 #include "cl_SF.h"
20 #include "cln/ffloat.h"
21 #include "cl_FF.h"
22 #include "cln/dfloat.h"
23 #include "cl_DF.h"
24 #include "cln/lfloat.h"
25 #include "cl_LF.h"
26 #include "cl_N.h"
27
28 namespace cln {
29
30 ALL_cl_LF_OPERATIONS_SAME_PRECISION()
31
32 const cl_R operator/ (const cl_R& x, const cl_R& y)
33 {
34         if (eq(x,0))
35                 // 0 / y = exakte 0, außer wenn y=0
36                 { if (zerop(y))
37                         { throw division_by_0_exception(); }
38                   else
39                         return 0;
40                 }
41         else
42 #define div(a,b) a/b
43         realcase6(x
44         , /* I */       
45                         realcase6(y
46                         , /* I */       return div(x,y);
47                         , /* RT */      return div(x,y);
48                         , /* SF */      return div(cl_I_to_SF(x),y);
49                         , /* FF */      return div(cl_I_to_FF(x),y);
50                         , /* DF */      return div(cl_I_to_DF(x),y);
51                         , /* LF */      return div(cl_I_to_LF(x,LFlen0(y)),y); // cf. cl_I_LF_div
52                         );
53         , /* RT */      
54                         realcase6(y
55                         , /* I */       return div(x,y);
56                         , /* RT */      return div(x,y);
57                         , /* SF */      return div(cl_RA_to_SF(x),y);
58                         , /* FF */      return div(cl_RA_to_FF(x),y);
59                         , /* DF */      return div(cl_RA_to_DF(x),y);
60                         , /* LF */      return cl_RA_LF_div(x,y);
61                         );
62         , /* SF */      
63                         realcase6(y
64                         , /* I */       return div(x,cl_I_to_SF(y));
65                         , /* RT */      return div(x,cl_RA_to_SF(y));
66                         , /* SF */      return div(x,y);
67                         , /* FF */      return cl_FF_to_SF(div(cl_SF_to_FF(x),y));
68                         , /* DF */      return cl_DF_to_SF(div(cl_SF_to_DF(x),y));
69                         , /* LF */      return cl_LF_to_SF(div(cl_SF_to_LF(x,LFlen0(y)),y));
70                         );
71         , /* FF */      
72                         realcase6(y
73                         , /* I */       return div(x,cl_I_to_FF(y));
74                         , /* RT */      return div(x,cl_RA_to_FF(y));
75                         , /* SF */      return cl_FF_to_SF(div(x,cl_SF_to_FF(y)));
76                         , /* FF */      return div(x,y);
77                         , /* DF */      return cl_DF_to_FF(div(cl_FF_to_DF(x),y));
78                         , /* LF */      return cl_LF_to_FF(div(cl_FF_to_LF(x,LFlen0(y)),y));
79                         );
80         , /* DF */      
81                         realcase6(y
82                         , /* I */       return div(x,cl_I_to_DF(y));
83                         , /* RT */      return div(x,cl_RA_to_DF(y));
84                         , /* SF */      return cl_DF_to_SF(div(x,cl_SF_to_DF(y)));
85                         , /* FF */      return cl_DF_to_FF(div(x,cl_FF_to_DF(y)));
86                         , /* DF */      return div(x,y);
87                         , /* LF */      return cl_LF_to_DF(div(cl_DF_to_LF(x,LFlen0(y)),y));
88                         );
89         , /* LF */      
90                         realcase6(y
91                         , /* I */       return cl_LF_I_div(x,y);
92                         , /* RT */      return cl_LF_RA_div(x,y);
93                         , /* SF */      return cl_LF_to_SF(div(x,cl_SF_to_LF(y,LFlen0(x))));
94                         , /* FF */      return cl_LF_to_FF(div(x,cl_FF_to_LF(y,LFlen0(x))));
95                         , /* DF */      return cl_LF_to_DF(div(x,cl_DF_to_LF(y,LFlen0(x))));
96                         , /* LF */      return div(x,y);
97                         );
98         );
99 }
100
101 }  // namespace cln