/[ascend]/trunk/base/generic/compiler/fractions.h
ViewVC logotype

Contents of /trunk/base/generic/compiler/fractions.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1063 - (show annotations) (download) (as text)
Sun Jan 7 07:54:06 2007 UTC (17 years, 9 months ago) by johnpye
File MIME type: text/x-chdr
File size: 2606 byte(s)
Changed ASC_DLLSPEC(TYPE) to ASC_DLLSPEC TYPE, because it was causing havoc with doxygen and ctags.
1 /* ASCEND modelling environment
2 Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
3 Copyright (C) 2006 Carnegie Mellon University
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
8 any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19 *//**
20 @file
21 Fraction module for ASCEND.
22
23 Requires:
24 #include <utilities/ascConfig.h>
25 *//*
26 by Tom Epperly
27 8/18/89
28 Version: $Revision: 1.5 $
29 Version control file: $RCSfile: fractions.h,v $
30 Date last modified: $Date: 1997/07/18 12:29:47 $
31 Last modified by: $Author: mthomas $
32 */
33
34 #ifndef ASC_FRACTIONS_H
35 #define ASC_FRACTIONS_H
36
37 /** The type of a fraction numerator or denominator. */
38 #define FRACPART short
39 /** The maximum FRACPART value. */
40 #define FRACMAX SHRT_MAX
41
42 /** Fraction data structure. */
43 struct fraction {
44 FRACPART numerator;
45 FRACPART denominator;
46 };
47
48 ASC_DLLSPEC struct fraction CreateFraction(short n, short d);
49 /**<
50 * Create a fraction (n/d).
51 * Specify the numerator (n) and denominator (d).
52 */
53
54 extern struct fraction Simplify(struct fraction f);
55 /**<
56 * Simplify the fraction. This forces the denominator to be >= 0; so
57 * if the fraction is negative, the numerator will be negative.
58 */
59
60 #define Numerator(f) ((f).numerator)
61 /**<
62 * Return the numerator of f as a FRACPART.
63 */
64
65 #define Denominator(f) ((f).denominator)
66 /**<
67 * Return the denominator of f as a FRACPART.
68 */
69
70 extern struct fraction AddF(struct fraction f1, struct fraction f2);
71 /**<
72 * Return f1+f2 simplified.
73 */
74
75 extern struct fraction SubF(struct fraction f1, struct fraction f2);
76 /**<
77 * Return f1-f2 simplified.
78 */
79
80 extern struct fraction MultF(struct fraction f1, struct fraction f2);
81 /**<
82 * Return f1*f2 simplified.
83 */
84
85 extern struct fraction DivF(struct fraction f1, struct fraction f2);
86 /**<
87 * Return f1/f2 simplified.
88 */
89
90 extern int CmpF(struct fraction f1, struct fraction f2);
91 /**<
92 * Return -1,0,1 if f1 is <,=, or > than f2 respectively.
93 */
94
95 extern struct fraction NegateF(struct fraction f);
96 /**<
97 * Returned fraction equal -f.
98 */
99
100 #endif /* ASC_FRACTIONS_H */
101

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22