-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathReal.wurst
More file actions
108 lines (84 loc) · 3.34 KB
/
Copy pathReal.wurst
File metadata and controls
108 lines (84 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package Real
import NoWurst
import BasicTypeClasses
public constant REAL_MAX = 340282366920938000000000000000000000000.
public constant REAL_MIN = -340282366920938000000000000000000000000.
/** Returns the abolsute value of the given real.
This means, negative values will be return positive. */
public function real.abs() returns real
return this < 0 ? -this : this
/** Returns the result of this * this, i.e. the square */
public function real.squared() returns real
return this * this
/** Returns the sign of this real */
public function real.sign() returns int
return (this > 0 ? 1 : (this < 0 ? -1 : 0))
/** Rounds the input real to the nearest int */
public function real.round() returns int
return this > 0 ? (this + .5).toInt() : (this - .5).toInt()
/** Rounds the input real towards zero to the nearest int */
public function real.trunc() returns int
return this.toInt()
/** Rounds the input real downward to the nearest int */
public function real.floor() returns int
var r = this.toInt()
if this < 0 and this - r != 0.
r -= 1
return r
/** Rounds the input real upward to the nearest int */
public function real.ceil() returns int
var r = this.toInt()
if this > 0 and this - r != 0.
r += 1
return r
/** Limits the input real to the given range */
public function real.clamp(real lowerBound, real higherBound) returns real
return (this <= lowerBound ? lowerBound : (this >= higherBound ? higherBound : this))
/** Converts the input real to an int. This cuts off
the decimal digits. (1.9 -> 1) */
public function real.toInt() returns int
return R2I(this)
/** Returns the string representation of this real */
public function real.toString() returns string
return R2S(this)
public implements Show<real>
override function toString(real b) returns string
return b.toString()
/** Returns the string representation of this real with the given amount if digits precision */
public function real.toString(int precision) returns string
return R2SW(this, precision, precision)
/** The inverse trigonometric function of cosine */
public function real.acos() returns real
return Acos(this)
/** The inverse trigonometric function of sine */
public function real.asin() returns real
return Asin(this)
/** The inverse trigonometric function of tangent */
public function real.atan() returns real
return Atan(this)
/** The trigonometric function of cosine */
public function real.cos() returns real
return Cos(this)
/** The trigonometric function of sine */
public function real.sin() returns real
return Sin(this)
/** The trigonometric function of tangent */
public function real.tan() returns real
return Tan(this)
/** The arctangent function with two arguments.
The second argument is needed to determine the appropriate
quadrant of the computed angle. */
public function real.atan2(real y) returns real
return Atan2(y, this)
/** Returns this real to the power of the argument real */
public function real.pow(real x) returns real
return Pow(this, x)
/** Linear Interpolation with alphafactor(smoothness) */
public function real.lerp(real target, real alpha) returns real
return (this * (1.0 - alpha)) + (target * alpha)
/** Checks if this real is between low and high value */
public function real.isBetween(real low, real high) returns bool
return this >= low and this <= high
public implements Default<real>
override function defaultValue() returns real
return 0.