BadScript 2
Loading...
Searching...
No Matches
BadMathApi.cs
Go to the documentation of this file.
3
5
9[BadInteropApi("Math")]
10internal partial class BadMathApi
11{
15 private static readonly Random s_Random = new Random();
16
17 protected override void AdditionalData(BadTable target)
18 {
19 target.SetProperty("PI", (decimal)Math.PI);
20 target.SetProperty("E", (decimal)Math.E);
21 target.SetProperty("Tau", (decimal)Math.PI * 2);
22 }
23
24 [BadMethod(description: "Returns the absolute value of a number")]
25 [return: BadReturn("A decimal number, x, such that 0 \u2264 x \u2264MaxValue.")]
26 private decimal Abs(
27 [BadParameter(description:
28 "A number that is greater than or equal to MinValue, but less than or equal to MaxValue."
29 )]
30 decimal x)
31 {
32 return Math.Abs(x);
33 }
34
35 [BadMethod(description: "Returns the angle whose sine is the specified number.")]
36 [return:
37 BadReturn("An angle, θ, measured in radians, such that -π/2 \u2264θ\u2264π/2 -or- NaN if x < -1 or x > 1 or x equals NaN."
38 )]
39 private decimal Asin(
40 [BadParameter(description:
41 "A number representing a sine, where x must be greater than or equal to -1, but less than or equal to 1"
42 )]
43 decimal x)
44 {
45 return (decimal)Math.Asin((double)x);
46 }
47
48 [BadMethod(description: "Returns the angle whose cosine is the specified number.")]
49 [return:
50 BadReturn("An angle, θ, measured in radians, such that 0 \u2264θ\u2264π -or- NaN if x < -1 or x > 1 or x equals NaN."
51 )]
52 private decimal Acos(
53 [BadParameter(description:
54 "A number representing a cosine, where x must be greater than or equal to -1, but less than or equal to 1"
55 )]
56 decimal x)
57 {
58 return (decimal)Math.Acos((double)x);
59 }
60
61 [BadMethod(description: "Returns the angle whose tangent is the specified number.")]
62 [return:
63 BadReturn("An angle, θ, measured in radians, such that -π/2 \u2264θ\u2264π/2. -or- NaN if x equals NaN, -π/2 rounded to double precision (-1.5707963267949) if x equals NegativeInfinity, or π/2 rounded to double precision (1.5707963267949) if x equals PositiveInfinity."
64 )]
65 private decimal Atan([BadParameter(description: "A number representing a tangent")] decimal x)
66 {
67 return (decimal)Math.Atan((double)x);
68 }
69
70 [BadMethod(description: "Returns the angle whose tangent is the quotient of two specified numbers.")]
71 [return:
72 BadReturn(
73 "An angle, θ, measured in radians, such that -π\u2264θ\u2264π, and tan(θ) = y / x, where (x, y) is a point in the Cartesian plane. Observe the following: For (x, y) in quadrant 1, 0 < θ < π/2. For (x, y) in quadrant 2, π/2 < θ\u2264π. For (x, y) in quadrant 3, -π < θ < -π/2. For (x, y) in quadrant 4, -π/2 < θ < 0. For points on the boundaries of the quadrants, the return value is the following: If y is 0 and x is not negative, θ = 0. If y is 0 and x is negative, θ = π. If y is positive and x is 0, θ = π/2. If y is negative and x is 0, θ = -π/2. If y is 0 and x is 0, θ = 0. If x or y is NaN, or if x and y are either PositiveInfinity or NegativeInfinity, the method returns NaN"
74 )]
75 private decimal Atan2([BadParameter(description: "The y coordinate of a point.")] decimal y,
76 [BadParameter(description: "The x coordinate of a point.")] decimal x)
77 {
78 return (decimal)Math.Atan2((double)y, (double)x);
79 }
80
81 [BadMethod(description: "Returns the smallest integer greater than or equal to the specified number.")]
82 [return:
83 BadReturn("The smallest integral value that is greater than or equal to x. Note that this method returns a Decimal instead of an integral type"
84 )]
85 private decimal Ceiling([BadParameter(description: "A decimal number.")] decimal x)
86 {
87 return Math.Ceiling(x);
88 }
89
90 [BadMethod(description: "Returns the cosine of the specified angle.")]
91 [return:
92 BadReturn("The cosine of x. If x is equal to NaN, NegativeInfinity, or PositiveInfinity, this method returns NaN."
93 )]
94 private decimal Cos([BadParameter(description: "An angle, measured in radians")] decimal x)
95 {
96 return (decimal)Math.Cos((double)x);
97 }
98
99 [BadMethod(description: "Returns the hyperbolic cosine of the specified angle.")]
100 [return:
101 BadReturn("The hyperbolic cosine of x. If x is equal to NegativeInfinity or PositiveInfinity, PositiveInfinity is returned. If x is equal to NaN, NaN is returned"
102 )]
103 private decimal Cosh([BadParameter(description: "An angle, measured in radians")] decimal x)
104 {
105 return (decimal)Math.Cosh((double)x);
106 }
107
108 [BadMethod(description: "Returns the value of e raised to the specified power.")]
109 [return:
110 BadReturn("The number e raised to the power x. If x equals NaN or PositiveInfinity, that value is returned. If x equals NegativeInfinity, 0 is returned."
111 )]
112 private decimal Exp([BadParameter(description: "A number specifying a power")] decimal x)
113 {
114 return (decimal)Math.Exp((double)x);
115 }
116
117 [BadMethod(description: "Returns the largest integer less than or equal to the specified number.")]
118 [return:
119 BadReturn("The largest integral value that is less than or equal to x. Note that this method returns a Decimal instead of an integral type"
120 )]
121 private decimal Floor([BadParameter(description: "A decimal number.")] decimal x)
122 {
123 return Math.Floor(x);
124 }
125
126 [BadMethod(description: "Returns the natural (base e) logarithm of a specified number.")]
127 [return:
128 BadReturn("The natural logarithm of x; that is, ln x, where e is approximately equal to 2.71828182845904. If x is equal to NaN or NegativeInfinity, that value is returned. If x is equal to PositiveInfinity, PositiveInfinity is returned."
129 )]
130 private decimal Log([BadParameter(description: "A decimal number.")] decimal x)
131 {
132 return (decimal)Math.Log((double)x);
133 }
134
135 [BadMethod(description: "Returns the logarithm of a specified number with base 10.")]
136 [return:
137 BadReturn("The base 10 logarithm of x; that is, log10 x. If x is equal to NaN or NegativeInfinity, that value is returned. If x is equal to PositiveInfinity, PositiveInfinity is returned."
138 )]
139 private decimal Log10([BadParameter(description: "A decimal number.")] decimal x)
140 {
141 return (decimal)Math.Log10((double)x);
142 }
143
144 [BadMethod(description: "Returns the larger of two numbers.")]
145 [return: BadReturn("The larger of x or y. If x, or y, or both x and y are equal to NaN, NaN is returned.")]
146 private decimal Max([BadParameter(description: "The first of two decimal numbers to compare.")] decimal x,
147 [BadParameter(description: "The second of two decimal numbers to compare.")]
148 decimal y)
149 {
150 return Math.Max(x, y);
151 }
152
153 [BadMethod(description: "Returns the smaller of two numbers.")]
154 [return: BadReturn("The smaller of x or y. If x, or y, or both x and y are equal to NaN, NaN is returned.")]
155 private decimal Min([BadParameter(description: "The first of two decimal numbers to compare.")] decimal x,
156 [BadParameter(description: "The second of two decimal numbers to compare.")]
157 decimal y)
158 {
159 return Math.Min(x, y);
160 }
161
162 [BadMethod(description: "Returns a specified number raised to the specified power.")]
163 [return: BadReturn("The number x raised to the power y.")]
164 private decimal Pow(
165 [BadParameter(description: "A double-precision floating-point number to be raised to a power")] decimal x,
166 [BadParameter(description: "A double-precision floating-point number that specifies a power")]
167 decimal y)
168 {
169 return (decimal)Math.Pow((double)x, (double)y);
170 }
171
172 [BadMethod(description: "Rounds a value to the nearest integer or to the specified number of decimal places.")]
173 [return: BadReturn("The number nearest to x that contains a number of fractional digits equal to decimals.")]
174 private decimal Round([BadParameter(description: "A decimal number to be rounded")] decimal x,
175 [BadParameter(description:
176 "The number nearest to x that contains a number of fractional digits equal to decimals"
177 )]
178 int y)
179 {
180 return Math.Round(x, y);
181 }
182
183 [BadMethod(description: "Returns a value indicating the sign of a number.")]
184 [return:
185 BadReturn("A number that indicates the sign of x, as shown in the following table. Value Meaning -1 x is less than zero. 0 x is equal to zero. 1 x is greater than zero."
186 )]
187 private decimal Sign([BadParameter(description: "A decimal number.")] decimal x)
188 {
189 return Math.Sign(x);
190 }
191
192 [BadMethod(description: "Returns the sine of the specified angle.")]
193 [return:
194 BadReturn("The sine of x. If x is equal to NaN, NegativeInfinity, or PositiveInfinity, this method returns NaN."
195 )]
196 private decimal Sin([BadParameter(description: "An angle, measured in radians")] decimal x)
197 {
198 return (decimal)Math.Sin((double)x);
199 }
200
201 [BadMethod(description: "Returns the hyperbolic sine of the specified angle.")]
202 [return:
203 BadReturn("The hyperbolic sine of x. If x is equal to NegativeInfinity, NegativeInfinity is returned. If x is equal to PositiveInfinity, PositiveInfinity is returned. If x is equal to NaN, NaN is returned."
204 )]
205 private decimal Sinh([BadParameter(description: "An angle, measured in radians")] decimal x)
206 {
207 return (decimal)Math.Sinh((double)x);
208 }
209
210 [BadMethod(description: "Returns the square root of a specified number.")]
211 [return:
212 BadReturn("The positive square root of x. If x is equal to NaN, NegativeInfinity, or PositiveInfinity, that value is returned."
213 )]
214 private decimal Sqrt([BadParameter(description: "A decimal number.")] decimal x)
215 {
216 return (decimal)Math.Sqrt((double)x);
217 }
218
219 [BadMethod(description: "Returns the tangent of the specified angle.")]
220 [return:
221 BadReturn("The tangent of x. If x is equal to NaN, NegativeInfinity, or PositiveInfinity, this method returns NaN."
222 )]
223 private decimal Tan([BadParameter(description: "An angle, measured in radians")] decimal x)
224 {
225 return (decimal)Math.Tan((double)x);
226 }
227
228 [BadMethod(description: "Returns the hyperbolic tangent of the specified angle.")]
229 [return:
230 BadReturn("The hyperbolic tangent of x. If x is equal to NegativeInfinity, -1 is returned. If x is equal to PositiveInfinity, 1 is returned. If x is equal to NaN, NaN is returned."
231 )]
232 private decimal Tanh([BadParameter(description: "An angle, measured in radians")] decimal x)
233 {
234 return (decimal)Math.Tanh((double)x);
235 }
236
237 [BadMethod(description: "Returns the integral part of a specified decimal number.")]
238 [return:
239 BadReturn("The integral part of d; that is, the number that remains after any fractional digits have been discarded."
240 )]
241 private decimal Truncate([BadParameter(description: "A number to truncate")] decimal x)
242 {
243 return Math.Truncate(x);
244 }
245
246 [BadMethod(description: "Returns a random number between 0.0 and 1.0.")]
247 [return: BadReturn("A double-precision floating point number greater than or equal to 0.0, and less than 1.0.")]
248 private decimal NextRandom()
249 {
250 return (decimal)s_Random.NextDouble();
251 }
252}
decimal Acos([BadParameter(description:"A number representing a cosine, where x must be greater than or equal to -1, but less than or equal to 1")] decimal x)
Definition BadMathApi.cs:52
decimal Round([BadParameter(description:"A decimal number to be rounded")] decimal x, [BadParameter(description:"The number nearest to x that contains a number of fractional digits equal to decimals")] int y)
decimal Sin([BadParameter(description:"An angle, measured in radians")] decimal x)
decimal Atan([BadParameter(description:"A number representing a tangent")] decimal x)
Definition BadMathApi.cs:65
decimal Sign([BadParameter(description:"A decimal number.")] decimal x)
decimal Truncate([BadParameter(description:"A number to truncate")] decimal x)
decimal Atan2([BadParameter(description:"The y coordinate of a point.")] decimal y, [BadParameter(description:"The x coordinate of a point.")] decimal x)
Definition BadMathApi.cs:75
decimal Pow([BadParameter(description:"A double-precision floating-point number to be raised to a power")] decimal x, [BadParameter(description:"A double-precision floating-point number that specifies a power")] decimal y)
decimal Tan([BadParameter(description:"An angle, measured in radians")] decimal x)
decimal Log([BadParameter(description:"A decimal number.")] decimal x)
decimal Abs([BadParameter(description:"A number that is greater than or equal to MinValue, but less than or equal to MaxValue.")] decimal x)
Definition BadMathApi.cs:26
decimal Floor([BadParameter(description:"A decimal number.")] decimal x)
decimal Ceiling([BadParameter(description:"A decimal number.")] decimal x)
Definition BadMathApi.cs:85
decimal Asin([BadParameter(description:"A number representing a sine, where x must be greater than or equal to -1, but less than or equal to 1")] decimal x)
Definition BadMathApi.cs:39
decimal Cosh([BadParameter(description:"An angle, measured in radians")] decimal x)
decimal Cos([BadParameter(description:"An angle, measured in radians")] decimal x)
Definition BadMathApi.cs:94
decimal Min([BadParameter(description:"The first of two decimal numbers to compare.")] decimal x, [BadParameter(description:"The second of two decimal numbers to compare.")] decimal y)
override void AdditionalData(BadTable target)
Definition BadMathApi.cs:17
decimal Max([BadParameter(description:"The first of two decimal numbers to compare.")] decimal x, [BadParameter(description:"The second of two decimal numbers to compare.")] decimal y)
decimal Sqrt([BadParameter(description:"A decimal number.")] decimal x)
decimal Exp([BadParameter(description:"A number specifying a power")] decimal x)
decimal Sinh([BadParameter(description:"An angle, measured in radians")] decimal x)
decimal Tanh([BadParameter(description:"An angle, measured in radians")] decimal x)
static readonly Random s_Random
Random Number Generator.
Definition BadMathApi.cs:15
decimal Log10([BadParameter(description:"A decimal number.")] decimal x)
Implements an Interop API for the BS2 Language.
Implements a Table Structure for the BadScript Language.
Definition BadTable.cs:14
Contains Common Interop APIs for the BadScript2 Runtime.
Contains the Interop Abstractions and Implementations for the BadScript2 Language.
Contains the Runtime Objects.
Definition BadArray.cs:10