PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/cln-1.3.2/src/rational/input/cl_RA_readparsed.cc

#
C++ | 32 lines | 20 code | 8 blank | 4 comment | 3 complexity | d6b7ed645c6c55dfb653ce25500a7648 MD5 | raw file
Possible License(s): GPL-2.0
  1. // read_rational().
  2. // General includes.
  3. #include "base/cl_sysdep.h"
  4. // Specification.
  5. #include "cln/rational_io.h"
  6. // Implementation.
  7. #include "rational/cl_RA.h"
  8. #include "integer/cl_I.h"
  9. #include "base/cl_N.h"
  10. namespace cln {
  11. const cl_RA read_rational (unsigned int base, cl_signean sign, const char * string, uintC index1, uintC index3, uintC index2)
  12. {
  13. var uintC index3_1 = index3+1; // Index der ersten Nennerziffer
  14. var cl_I den = // Nenner
  15. digits_to_I(&string[index3_1],index2-index3_1,(uintD)base);
  16. if (zerop(den)) // Division durch 0 abfangen
  17. { throw division_by_0_exception(); }
  18. var cl_I num = // Z?hler
  19. digits_to_I(&string[index1],index3-index1,(uintD)base);
  20. if (!(sign == 0))
  21. num = -num; // incl. Vorzeichen
  22. return I_posI_div_RA(num,den);
  23. }
  24. } // namespace cln