PageRenderTime 42ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/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. // General includes.
  3. #include "base/cl_sysdep.h"
  4. // Specification.
  5. #include "float/lfloat/cl_LF.h"
  6. // Implementation.
  7. #include "cln/lfloat.h"
  8. #include "cln/rational.h"
  9. #include "rational/cl_RA.h"
  10. namespace cln {
  11. const cl_LF cl_LF_RA_div (const cl_LF& x, const cl_RA& y)
  12. {
  13. // Method:
  14. // Write y = u/v. Return (x*v)/u.
  15. if (integerp(y)) {
  16. DeclareType(cl_I,y);
  17. return cl_LF_I_div(x,y);
  18. } else {
  19. DeclareType(cl_RT,y);
  20. var const cl_I& u = TheRatio(y)->numerator; // u /= 0
  21. var const cl_I& v = TheRatio(y)->denominator; // v /= 0
  22. return cl_LF_I_div(The(cl_LF)(cl_LF_I_mul(x,v)),u);
  23. }
  24. }
  25. } // namespace cln