15 private static readonly Random
s_Random =
new Random();
19 target.SetProperty(
"PI", (decimal)Math.PI);
20 target.SetProperty(
"E", (decimal)Math.E);
21 target.SetProperty(
"Tau", (decimal)Math.PI * 2);
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)
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)
35 return (decimal)Math.Asin((
double)x);
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)
42 return (decimal)Math.Acos((
double)x);
45 [BadMethod(description:
"Returns the angle whose tangent is the specified number.")]
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."
50 private decimal
Atan([BadParameter(description:
"A number representing a tangent")] decimal x)
52 return (decimal)Math.Atan((
double)x);
55 [BadMethod(description:
"Returns the angle whose tangent is the quotient of two specified numbers.")]
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"
60 private decimal
Atan2([BadParameter(description:
"The y coordinate of a point.")] decimal y, [BadParameter(description:
"The x coordinate of a point.")] decimal x)
62 return (decimal)Math.Atan2((
double)y, (
double)x);
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)
69 return Math.Ceiling(x);
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)
76 return (decimal)Math.Cos((
double)x);
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)
83 return (decimal)Math.Cosh((
double)x);
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)
90 return (decimal)Math.Exp((
double)x);
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)
100 [BadMethod(description:
"Returns the natural (base e) logarithm of a specified number.")]
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."
105 private decimal
Log([BadParameter(description:
"A decimal number.")] decimal x)
107 return (decimal)Math.Log((
double)x);
110 [BadMethod(description:
"Returns the logarithm of a specified number with base 10.")]
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."
115 private decimal
Log10([BadParameter(description:
"A decimal number.")] decimal x)
117 return (decimal)Math.Log10((
double)x);
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.")]
123 [BadParameter(description:
"The first of two decimal numbers to compare.")]
125 [BadParameter(description:
"The second of two decimal numbers to compare.")]
128 return Math.Max(x, y);
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.")]
134 [BadParameter(description:
"The first of two decimal numbers to compare.")]
136 [BadParameter(description:
"The second of two decimal numbers to compare.")]
139 return Math.Min(x, y);
142 [BadMethod(description:
"Returns a specified number raised to the specified power.")]
143 [return: BadReturn(
"The number x raised to the power y.")]
145 [BadParameter(description:
"A double-precision floating-point number to be raised to a power")]
147 [BadParameter(description:
"A double-precision floating-point number that specifies a power")]
150 return (decimal)Math.Pow((
double)x, (
double)y);
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.")]
156 [BadParameter(description:
"A decimal number to be rounded")]
158 [BadParameter(description:
"The number nearest to x that contains a number of fractional digits equal to decimals")]
161 return Math.Round(x, y);
164 [BadMethod(description:
"Returns a value indicating the sign of a number.")]
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)
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)
176 return (decimal)Math.Sin((
double)x);
179 [BadMethod(description:
"Returns the hyperbolic sine of the specified angle.")]
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."
184 private decimal
Sinh([BadParameter(description:
"An angle, measured in radians")] decimal x)
186 return (decimal)Math.Sinh((
double)x);
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)
193 return (decimal)Math.Sqrt((
double)x);
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)
200 return (decimal)Math.Tan((
double)x);
203 [BadMethod(description:
"Returns the hyperbolic tangent of the specified angle.")]
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."
208 private decimal
Tanh([BadParameter(description:
"An angle, measured in radians")] decimal x)
210 return (decimal)Math.Tanh((
double)x);
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)
217 return Math.Truncate(x);
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.")]
224 return (decimal)
s_Random.NextDouble();
Implements the "Math" API.
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)
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)
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)
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)
decimal Floor([BadParameter(description:"A decimal number.")] decimal x)
decimal Ceiling([BadParameter(description:"A decimal number.")] decimal x)
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)
decimal Cosh([BadParameter(description:"An angle, measured in radians")] decimal x)
decimal Cos([BadParameter(description:"An angle, measured in radians")] decimal x)
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)
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.
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.
Contains Common Interop APIs for the BadScript2 Runtime.
Contains the Interop Abstractions and Implementations for the BadScript2 Language.
Contains the Runtime Objects.