PageRenderTime 70ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 0ms

/cln-1.3.2/src/real/elem/cl_R_compare.cc

#
C++ | 48 lines | 30 code | 8 blank | 10 comment | 4 complexity | d558bb52c5947f251c709aa07b64a2c4 MD5 | raw file
Possible License(s): GPL-2.0
  1. // compare().
  2. // General includes.
  3. #include "base/cl_sysdep.h"
  4. // Specification.
  5. #include "cln/real.h"
  6. // Implementation.
  7. #include "real/cl_R.h"
  8. #include "cln/rational.h"
  9. #include "cln/float.h"
  10. namespace cln {
  11. cl_signean compare (const cl_R& x, const cl_R& y)
  12. {
  13. // Methode:
  14. // Beide rational oder beide Floats -> klar.
  15. // Eine rational, eine Float ->
  16. // Die rationale Zahl zum Float machen, vergleichen.
  17. // Verschieden -> Das war's.
  18. // Gleich -> Das Float mit RATIONAL rational machen, nochmals vergleichen.
  19. realcase2(x
  20. , realcase2(y
  21. , // beides rationale Zahlen
  22. return compare(x,y);
  23. , // x rational, y Float -> x in Float umwandeln
  24. var cl_signean result = compare(cl_float(x,y),y);
  25. if (result != signean_null)
  26. return result;
  27. return compare(x,rational(y));
  28. );
  29. , realcase2(y
  30. , // x Float, y rational -> y in Float umwandeln
  31. var cl_signean result = compare(x,cl_float(y,x));
  32. if (result != signean_null)
  33. return result;
  34. return compare(rational(x),y);
  35. , // beides Floats
  36. return compare(x,y);
  37. );
  38. );
  39. }
  40. } // namespace cln