/[dtapublic]/to_be_filed/webprojs/php_libraries/php_lib_uculib_com/rat_string_arithmetic.inc
ViewVC logotype

Contents of /to_be_filed/webprojs/php_libraries/php_lib_uculib_com/rat_string_arithmetic.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 35 - (show annotations) (download)
Sat Oct 8 23:35:33 2016 UTC (8 years ago) by dashley
File size: 7095 byte(s)
Initial commit.
1 <?php
2 //********************************************************************************
3 //Copyright (C) 2007 David T. Ashley
4 //********************************************************************************
5 //This program or source file is free software; you can redistribute it and/or
6 //modify it under the terms of the GNU Lesser General Public License as published
7 //by the Free Software Foundation; either version 2 of the License, or (at your
8 //option) any later version.
9 //
10 //This program or source file is distributed in the hope that it will
11 //be useful, 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 may have received a copy of the GNU Lesser General Public License
16 //along with this program; if not, write to the Free Software
17 //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 //********************************************************************************
19 //Arithmetic on rational numbers expressed as strings.
20 //--------------------------------------------------------------------------------
21 //Format of rational numbers expressed as strings:
22 //
23 // a)Each rational number is "x:y", where x is an integer with an optional
24 // unary "-" sign, and y is a positive integer.
25 //
26 // b)In addition to numerical values, the string "NAN" (not a number) is
27 // recognized. "NAN" combined with anything else is "NAN".
28 //
29 // c)The canonical representation of zero is 0:y, where y is any positive
30 // integer.
31 //
32 // d)Rational numbers are not required to be reduced except where otherwise
33 // documented.
34 //
35 // d1)The arithmetic functions reduce results by default, but
36 // each has an optional argument to suppress reduction. The typical reasons
37 // for suppressing reduction are:
38 //
39 // d1a)Efficiency.
40 //
41 // d1b)Aesthetics -- some reason the output should be left as-is.
42 //
43 // d2)Functions that require reduced rational numbers must reduce
44 // them (in general).
45 //
46 // e)Only the numerator may carry an optional minus sign. The denominator
47 // must not have a negative sign.
48 //--------------------------------------------------------------------------------
49 //--------------------------------------------------------------------------------
50 //---- R E D U C T I O N -----------------------------------------------------
51 //--------------------------------------------------------------------------------
52 //--------------------------------------------------------------------------------
53 //Reduces a rational number as two components.
54 //
55 function RATSTRARITH_reduce_rn_components(&$arg_num, &$arg_den)
56 {
57 }
58 //
59 //--------------------------------------------------------------------------------
60 //Reduces a rational number in the allowable canonical form.
61 //
62 function RATSTRARITH_reduce_rn_integrated($in_rn)
63 {
64 }
65 //
66 //--------------------------------------------------------------------------------
67 //--------------------------------------------------------------------------------
68 //---- A S S I G N M E N T -----------------------------------------------------
69 //--------------------------------------------------------------------------------
70 //--------------------------------------------------------------------------------
71 //Assigns a rational number from two integers. Reduction can be suppressed, but
72 //treatment of sign and the canonical representation of zero cannot be
73 //suppressed.
74 //
75 //Arguments may be integers or strings or any mix.
76 //
77 function RATSTRARITH_assign_from_ints($in_num, $in_den, $in_suppress_reduction = FALSE)
78 {
79 }
80 //
81 //--------------------------------------------------------------------------------
82 //Splits a rational number in the canonical form as a string into components.
83 //
84 function RATSTRARITH_split($in_rn, &out_num, &$out_den, $in_suppress_reduction = FALSE)
85 {
86 }
87 //
88 //--------------------------------------------------------------------------------
89 //Assigns a rational number from a string. The formats accepted are:
90 // a)Integer format (i.e. "25", "-2,352", etc.).
91 // b)Scientific notation, i.e. "3.12451234e+3".
92 // c)Integer fraction, i.e. "412/332234".
93 //
94 //
95 function RATSTRARITH_assign_from_string($in_rn, &out_num, &$out_den, $in_suppress_reduction = FALSE)
96 {
97 }
98 //
99 //--------------------------------------------------------------------------------
100 //--------------------------------------------------------------------------------
101 //---- T E S T S ---------------------------------------------------------------
102 //--------------------------------------------------------------------------------
103 //--------------------------------------------------------------------------------
104 //Compares two rational numbers. NAN's in either operand always cause
105 //zero to be returned. Returned values are the traditional -1, 0, 1.
106 //
107 function RATSTRARITH_cmp($in_rn1, $in_rn2)
108 {
109 }
110 //
111 //--------------------------------------------------------------------------------
112 //Returns -1 if the rational number is < 0, 0 if it is 0, or 1 if it is
113 //positive. Returned value is integer rather than string. NAN causes
114 //return value of zero.
115 //
116 function RATSTRARITH_sgn($in_arg)
117 {
118 }
119 //
120 //--------------------------------------------------------------------------------
121 //Returns TRUE if the rational number is NAN, or FALSE otherwise.
122 //
123 function RATSTRARITH_is_nan($in_arg)
124 {
125 }
126 //
127 //--------------------------------------------------------------------------------
128 //Returns TRUE if the rational number is a whole integer, or FALSE otherwise.
129 //NAN causes return value of zero.
130 //
131 function RATSTRARITH_is_int($in_arg)
132 {
133 }
134 //
135 //--------------------------------------------------------------------------------
136 //--------------------------------------------------------------------------------
137 //---- E L E M E N T A L O P E R A T I O N S --------------------------------
138 //--------------------------------------------------------------------------------
139 //--------------------------------------------------------------------------------
140 //Adds two rational numbers.
141 //
142 function RATSTRARITH_add($in_rn1, $in_rn2, $in_suppress_reduction = FALSE)
143 {
144 }
145 //
146 //--------------------------------------------------------------------------------
147 //Subtracts two rational numbers.
148 //
149 function RATSTRARITH_sub($in_rn1, $in_rn2, $in_suppress_reduction = FALSE)
150 {
151 }
152 //
153 //--------------------------------------------------------------------------------
154 //Multiplies two rational numbers.
155 //
156 function RATSTRARITH_sub($in_rn1, $in_rn2, $in_suppress_reduction = FALSE)
157 {
158 }
159 //
160 //--------------------------------------------------------------------------------
161 //Divides two rational numbers.
162 //
163 function RATSTRARITH_div($in_rn1, $in_rn2, $in_suppress_reduction = FALSE)
164 {
165 }
166 //
167 //
168 ?>

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25