-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Float (data type)
Christoph Heine edited this page Mar 22, 2018
·
3 revisions
Floats are one of the primitive data types supported by nyan. They are used for representing fractions and rational numbers. Floats can be positive, negative or infinite (noted as inf
).
positive_float : float = 2.05
negative_float : float = -15.234
infinite_float : float = inf
Unit():
speed : float
Archer(Unit):
speed = 2.03
The float speed
has a value of 2.03
.
Archer(Unit):
speed = 1.05
FasterArchers<Archer>():
speed += 0.56
Adds a given value to the float.
Archer(Unit):
speed = 1.05
SlowerArchers<Archer>():
speed -= 0.56
Substracts a given value from the float.
Archer(Unit):
speed = 1.05
SpeedyArchers<Archer>():
speed *= 2.5
Multiplies a float by another float or an integer.
Archer(Unit):
speed = 1.05
SnailArchers<Archer>():
speed /= 1.5
Divides a float by another float or an integer.