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([BadParameter(description: "A number that is greater than or equal to MinValue, but less than or equal to MaxValue.")] decimal x)
27 {
28 return Math.Abs(x);
29 }
30
31 [BadMethod(description: "Returns the angle whose sine is the specified number.")]
32 [return: BadReturn("An angle, θ, measured in radians, such that -π/2 \u2264θ\u2264π/2 -or- NaN if x < -1 or x > 1 or x equals NaN.")]
33 private 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)
34 {
35 return (decimal)Math.Asin((double)x);
36 }
37
38 [BadMethod(description: "Returns the angle whose cosine is the specified number.")]
39 [return: BadReturn("An angle, θ, measured in radians, such that 0 \u2264θ\u2264π -or- NaN if x < -1 or x > 1 or x equals NaN.")]
40 private 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)
41 {
42 return (decimal)Math.Acos((double)x);
43 }
44
45 [BadMethod(description: "Returns the angle whose tangent is the specified number.")]
46 [return:
47 BadReturn(
48 "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."
49 )]
50 private decimal Atan([BadParameter(description: "A number representing a tangent")] decimal x)
51 {
52 return (decimal)Math.Atan((double)x);
53 }
54
55 [BadMethod(description: "Returns the angle whose tangent is the quotient of two specified numbers.")]
56 [return:
57 BadReturn(
58 "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"
59 )]
60 private decimal Atan2([BadParameter(description: "The y coordinate of a point.")] decimal y, [BadParameter(description: "The x coordinate of a point.")] decimal x)
61 {
62 return (decimal)Math.Atan2((double)y, (double)x);
63 }
64
65 [BadMethod(description: "Returns the smallest integer greater than or equal to the specified number.")]
66 [return: 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")]
67 private decimal Ceiling([BadParameter(description: "A decimal number.")] decimal x)
68 {
69 return Math.Ceiling(x);
70 }
71
72 [BadMethod(description: "Returns the cosine of the specified angle.")]
73 [return: BadReturn("The cosine of x. If x is equal to NaN, NegativeInfinity, or PositiveInfinity, this method returns NaN.")]
74 private decimal Cos([BadParameter(description: "An angle, measured in radians")] decimal x)
75 {
76 return (decimal)Math.Cos((double)x);
77 }
78
79 [BadMethod(description: "Returns the hyperbolic cosine of the specified angle.")]
80 [return: 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")]
81 private decimal Cosh([BadParameter(description: "An angle, measured in radians")] decimal x)
82 {
83 return (decimal)Math.Cosh((double)x);
84 }
85
86 [BadMethod(description: "Returns the value of e raised to the specified power.")]
87 [return: 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.")]
88 private decimal Exp([BadParameter(description: "A number specifying a power")] decimal x)
89 {
90 return (decimal)Math.Exp((double)x);
91 }
92
93 [BadMethod(description: "Returns the largest integer less than or equal to the specified number.")]
94 [return: 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")]
95 private decimal Floor([BadParameter(description: "A decimal number.")] decimal x)
96 {
97 return Math.Floor(x);
98 }
99
100 [BadMethod(description: "Returns the natural (base e) logarithm of a specified number.")]
101 [return:
102 BadReturn(
103 "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."
104 )]
105 private decimal Log([BadParameter(description: "A decimal number.")] decimal x)
106 {
107 return (decimal)Math.Log((double)x);
108 }
109
110 [BadMethod(description: "Returns the logarithm of a specified number with base 10.")]
111 [return:
112 BadReturn(
113 "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."
114 )]
115 private decimal Log10([BadParameter(description: "A decimal number.")] decimal x)
116 {
117 return (decimal)Math.Log10((double)x);
118 }
119
120 [BadMethod(description: "Returns the larger of two numbers.")]
121 [return: BadReturn("The larger of x or y. If x, or y, or both x and y are equal to NaN, NaN is returned.")]
122 private decimal Max(
123 [BadParameter(description: "The first of two decimal numbers to compare.")]
124 decimal x,
125 [BadParameter(description: "The second of two decimal numbers to compare.")]
126 decimal y)
127 {
128 return Math.Max(x, y);
129 }
130
131 [BadMethod(description: "Returns the smaller of two numbers.")]
132 [return: BadReturn("The smaller of x or y. If x, or y, or both x and y are equal to NaN, NaN is returned.")]
133 private decimal Min(
134 [BadParameter(description: "The first of two decimal numbers to compare.")]
135 decimal x,
136 [BadParameter(description: "The second of two decimal numbers to compare.")]
137 decimal y)
138 {
139 return Math.Min(x, y);
140 }
141
142 [BadMethod(description: "Returns a specified number raised to the specified power.")]
143 [return: BadReturn("The number x raised to the power y.")]
144 private decimal Pow(
145 [BadParameter(description: "A double-precision floating-point number to be raised to a power")]
146 decimal x,
147 [BadParameter(description: "A double-precision floating-point number that specifies a power")]
148 decimal y)
149 {
150 return (decimal)Math.Pow((double)x, (double)y);
151 }
152
153 [BadMethod(description: "Rounds a value to the nearest integer or to the specified number of decimal places.")]
154 [return: BadReturn("The number nearest to x that contains a number of fractional digits equal to decimals.")]
155 private decimal Round(
156 [BadParameter(description: "A decimal number to be rounded")]
157 decimal x,
158 [BadParameter(description: "The number nearest to x that contains a number of fractional digits equal to decimals")]
159 int y)
160 {
161 return Math.Round(x, y);
162 }
163
164 [BadMethod(description: "Returns a value indicating the sign of a number.")]
165 [return:
166 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.")]
167 private decimal Sign([BadParameter(description: "A decimal number.")] decimal x)
168 {
169 return Math.Sign(x);
170 }
171
172 [BadMethod(description: "Returns the sine of the specified angle.")]
173 [return: BadReturn("The sine of x. If x is equal to NaN, NegativeInfinity, or PositiveInfinity, this method returns NaN.")]
174 private decimal Sin([BadParameter(description: "An angle, measured in radians")] decimal x)
175 {
176 return (decimal)Math.Sin((double)x);
177 }
178
179 [BadMethod(description: "Returns the hyperbolic sine of the specified angle.")]
180 [return:
181 BadReturn(
182 "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."
183 )]
184 private decimal Sinh([BadParameter(description: "An angle, measured in radians")] decimal x)
185 {
186 return (decimal)Math.Sinh((double)x);
187 }
188
189 [BadMethod(description: "Returns the square root of a specified number.")]
190 [return: BadReturn("The positive square root of x. If x is equal to NaN, NegativeInfinity, or PositiveInfinity, that value is returned.")]
191 private decimal Sqrt([BadParameter(description: "A decimal number.")] decimal x)
192 {
193 return (decimal)Math.Sqrt((double)x);
194 }
195
196 [BadMethod(description: "Returns the tangent of the specified angle.")]
197 [return: BadReturn("The tangent of x. If x is equal to NaN, NegativeInfinity, or PositiveInfinity, this method returns NaN.")]
198 private decimal Tan([BadParameter(description: "An angle, measured in radians")] decimal x)
199 {
200 return (decimal)Math.Tan((double)x);
201 }
202
203 [BadMethod(description: "Returns the hyperbolic tangent of the specified angle.")]
204 [return:
205 BadReturn(
206 "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."
207 )]
208 private decimal Tanh([BadParameter(description: "An angle, measured in radians")] decimal x)
209 {
210 return (decimal)Math.Tanh((double)x);
211 }
212
213 [BadMethod(description: "Returns the integral part of a specified decimal number.")]
214 [return: BadReturn("The integral part of d; that is, the number that remains after any fractional digits have been discarded.")]
215 private decimal Truncate([BadParameter(description: "A number to truncate")] decimal x)
216 {
217 return Math.Truncate(x);
218 }
219
220 [BadMethod(description: "Returns a random number between 0.0 and 1.0.")]
221 [return: BadReturn("A double-precision floating point number greater than or equal to 0.0, and less than 1.0.")]
222 private decimal NextRandom()
223 {
224 return (decimal)s_Random.NextDouble();
225 }
226}
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:40
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:50
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:60
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)
Definition BadMathApi.cs:95
decimal Ceiling([BadParameter(description:"A decimal number.")] decimal x)
Definition BadMathApi.cs:67
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:33
decimal Cosh([BadParameter(description:"An angle, measured in radians")] decimal x)
Definition BadMathApi.cs:81
decimal Cos([BadParameter(description:"An angle, measured in radians")] decimal x)
Definition BadMathApi.cs:74
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)
Definition BadMathApi.cs:88
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