rational.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * This file is part of OpenModelica.
  3. *
  4. * Copyright (c) 1998-CurrentYear, Open Source Modelica Consortium (OSMC),
  5. * c/o Linköpings universitet, Department of Computer and Information Science,
  6. * SE-58183 Linköping, Sweden.
  7. *
  8. * All rights reserved.
  9. *
  10. * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE
  11. * GPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
  12. * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
  13. * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
  14. * ACCORDING TO RECIPIENTS CHOICE.
  15. *
  16. * The OpenModelica software and the OSMC (Open Source Modelica Consortium)
  17. * Public License (OSMC-PL) are obtained from OSMC, either from the above
  18. * address, from the URLs: http://www.openmodelica.org or
  19. * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica
  20. * distribution. GNU version 3 is obtained from:
  21. * http://www.gnu.org/copyleft/gpl.html. The New BSD License is obtained from:
  22. * http://www.opensource.org/licenses/BSD-3-Clause.
  23. *
  24. * This program is distributed WITHOUT ANY WARRANTY; without even the implied
  25. * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS
  26. * EXPRESSLY SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE
  27. * CONDITIONS OF OSMC-PL.
  28. *
  29. */
  30. #ifndef _RATIONAL_H_
  31. #define _RATIONAL_H_
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /* m/n */
  36. typedef struct RATIONAL {
  37. long m;
  38. long n;
  39. } RATIONAL;
  40. RATIONAL makeRATIONAL(long a, long b);
  41. RATIONAL addInt2Rat(long a, RATIONAL b);
  42. RATIONAL subInt2Rat(long a, RATIONAL b);
  43. RATIONAL addRat2Rat(RATIONAL a, RATIONAL b);
  44. RATIONAL multRat2Rat(RATIONAL a, RATIONAL b);
  45. RATIONAL divRat2Rat(RATIONAL a, RATIONAL b);
  46. RATIONAL multInt2Rat(long a, RATIONAL b);
  47. double rat2Real(RATIONAL a);
  48. long ceilRat(RATIONAL a);
  49. long ceilRatStrict(RATIONAL a);
  50. long floorRat(RATIONAL a);
  51. long floorRatStrict(RATIONAL a);
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif