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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 54 - (hide annotations) (download) (as text)
Tue Aug 2 11:20:09 2005 UTC (15 years ago) by jds
File MIME type: text/x-chdr
File size: 4364 byte(s)
Manual rework of doxygen comments in all headers.
- Added @file comment to all headers.
- Added parameter names to all function declarations in headers.
- Corrected comment referencing where necessary.
- Split some comments which documented blocks of declarations.
- Converted notes about required work into @todo comments so doxygen can generate a todo list.
Minor bug fixes.
1 jds 54 /*
2 aw0a 1 * Fraction module for ASCEND
3     * by Tom Epperly
4     * 8/18/89
5     * Version: $Revision: 1.5 $
6     * Version control file: $RCSfile: fractions.h,v $
7     * Date last modified: $Date: 1997/07/18 12:29:47 $
8     * Last modified by: $Author: mthomas $
9     *
10     * This file is part of the Ascend Language Interpreter.
11     *
12     * Copyright (C) 1990, 1993, 1994 Thomas Guthrie Epperly
13     *
14     * The Ascend Language Interpreter is free software; you can redistribute
15     * it and/or modify it under the terms of the GNU General Public License as
16     * published by the Free Software Foundation; either version 2 of the
17     * License, or (at your option) any later version.
18     *
19     * The Ascend Language Interpreter is distributed in hope that it will be
20     * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
21     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22     * General Public License for more details.
23     *
24     * You should have received a copy of the GNU General Public License
25     * along with the program; if not, write to the Free Software Foundation,
26     * Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named
27     * COPYING.
28     */
29    
30 jds 54 /** @file
31     * Fraction module for ASCEND.
32     * <pre>
33 aw0a 1 * When #including fractions.h, make sure these files are #included first:
34 jds 54 * #include "utilities/ascConfig,h"
35     * </pre>
36 aw0a 1 */
37    
38 jds 54 #ifndef __FRACTIONS_H_SEEN__
39     #define __FRACTIONS_H_SEEN__
40 aw0a 1
41 jds 54 /** The type of a fraction numerator or denominator. */
42 aw0a 1 #define FRACPART short
43 jds 54 /** The maximum FRACPART value. */
44 aw0a 1 #define FRACMAX SHRT_MAX
45 jds 54
46     /** Fraction data structure. */
47 aw0a 1 struct fraction {
48 jds 54 FRACPART numerator;
49     FRACPART denominator;
50 aw0a 1 };
51    
52 jds 54 extern struct fraction CreateFraction(short n, short d);
53 ben.allan 33 /**<
54 jds 54 * <!-- struct fraction CreateFraction(n,d) -->
55     * <!-- short n,d; -->
56     * Create a fraction (n/d).
57     * Specify the numerator (n) and denominator (d).
58 aw0a 1 */
59    
60 jds 54 extern struct fraction Simplify(struct fraction f);
61     /**<
62     * <!-- struct fraction Simplify(f) -->
63     * <!-- struct fraction f; -->
64 aw0a 1 * Simplify the fraction. This forces the denominator to be >= 0; so
65     * if the fraction is negative, the numerator will be negative.
66     */
67    
68     #define Numerator(f) ((f).numerator)
69 ben.allan 33 /**<
70 jds 54 * <!-- macro Numerator(f) -->
71     * <!-- struct fraction f; -->
72     * Return the numerator of f as a FRACPART.
73 aw0a 1 */
74    
75     #define Denominator(f) ((f).denominator)
76 ben.allan 33 /**<
77 jds 54 * <!-- macro Denominator(f) -->
78     * <!-- struct fraction f; -->
79     * Return the denominator of f as a FRACPART.
80 aw0a 1 */
81    
82 jds 54 extern struct fraction AddF(struct fraction f1, struct fraction f2);
83 ben.allan 33 /**<
84 jds 54 * <!-- struct fraction AddF(f1,f2) -->
85     * <!-- struct fraction f1,f2; -->
86 aw0a 1 * Return f1+f2 simplified.
87     */
88    
89 jds 54 extern struct fraction SubF(struct fraction f1, struct fraction f2);
90 ben.allan 33 /**<
91 jds 54 * <!-- struct fraction SubF(f1,f2) -->
92     * <!-- struct fraction f1,f2; -->
93 aw0a 1 * Return f1-f2 simplified.
94     */
95    
96 jds 54 extern struct fraction MultF(struct fraction f1, struct fraction f2);
97 ben.allan 33 /**<
98 jds 54 * <!-- struct fraction MultF(f1,f2) -->
99     * <!-- struct fraction f1,f2; -->
100 aw0a 1 * Return f1*f2 simplified.
101     */
102    
103 jds 54 extern struct fraction DivF(struct fraction f1, struct fraction f2);
104 ben.allan 33 /**<
105 jds 54 * <!-- struct fraction DivF(f1,f2) -->
106     * <!-- struct fraction f1,f2; -->
107 aw0a 1 * Return f1/f2 simplified.
108     */
109    
110 jds 54 extern int CmpF(struct fraction f1, struct fraction f2);
111 ben.allan 33 /**<
112 jds 54 * <!-- int CmpF(f1,f2) -->
113     * <!-- struct fraction f1,f2; -->
114 aw0a 1 * Return -1,0,1 if f1 is <,=, or > than f2 respectively.
115     */
116    
117 jds 54 extern struct fraction NegateF(struct fraction f);
118 ben.allan 33 /**<
119 jds 54 * <!-- struct fraction NegateF(f) -->
120     * <!-- struct fraction f; -->
121 aw0a 1 * Returned fraction equal -f.
122     */
123 jds 54
124     #endif /* __FRACTIONS_H_SEEN__ */
125    

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