2017-09-12 20:42:36 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2023-03-01 00:44:37 +00:00
<class name= "int" version= "4.1" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2017-09-12 20:42:36 +00:00
<brief_description >
2023-04-27 23:35:33 +00:00
A built-in type for integers.
2017-09-12 20:42:36 +00:00
</brief_description>
<description >
2022-12-14 06:40:50 +00:00
Signed 64-bit integer type. This means that it can take values from [code]-2^63[/code] to [code]2^63 - 1[/code], i.e. from [code]-9223372036854775808[/code] to [code]9223372036854775807[/code]. When it exceeds these bounds, it will wrap around.
[int]s can be automatically converted to [float]s when necessary, for example when passing them as arguments in functions. The [float] will be as close to the original integer as possible.
Likewise, [float]s can be automatically converted into [int]s. This will truncate the [float], discarding anything after the floating point.
[b]Note:[/b] In a boolean context, an [int] will evaluate to [code]false[/code] if it equals [code]0[/code], and to [code]true[/code] otherwise.
2020-10-30 23:37:55 +00:00
[codeblocks]
[gdscript]
2022-12-14 06:40:50 +00:00
var x: int = 1 # x is 1
x = 4.2 # x is 4, because 4.2 gets truncated
var max_int = 9223372036854775807 # Biggest value an int can store
max_int += 1 # max_int is -9223372036854775808, because it wrapped around
2020-10-30 23:37:55 +00:00
[/gdscript]
[csharp]
2022-12-14 06:40:50 +00:00
int x = 1; // x is 1
x = 4.2; // x is 4, because 4.2 gets truncated
// We use long below, because GDScript's int is 64-bit while C#'s int is 32-bit.
long maxLong = 9223372036854775807; // Biggest value a long can store
maxLong++; // maxLong is now -9223372036854775808, because it wrapped around.
2020-10-30 23:37:55 +00:00
2022-12-14 06:40:50 +00:00
// Alternatively with C#'s 32-bit int type, which has a smaller maximum value.
int maxInt = 2147483647; // Biggest value an int can store
maxInt++; // maxInt is now -2147483648, because it wrapped around
2020-10-30 23:37:55 +00:00
[/csharp]
[/codeblocks]
2022-12-14 06:40:50 +00:00
In GDScript, you can use the [code]0b[/code] literal for binary representation, the [code]0x[/code] literal for hexadecimal representation, and the [code]_[/code] symbol to separate long numbers and improve readability.
[codeblock]
var x = 0b1001 # x is 9
var y = 0xF5 # y is 245
var z = 10_000_000 # z is 10000000
[/codeblock]
2017-09-12 20:42:36 +00:00
</description>
<tutorials >
</tutorials>
2021-09-21 02:49:02 +00:00
<constructors >
<constructor name= "int" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2020-11-09 16:46:03 +00:00
<description >
2022-12-14 06:40:50 +00:00
Constructs an [int] set to [code]0[/code].
2020-11-09 16:46:03 +00:00
</description>
2021-09-21 02:49:02 +00:00
</constructor>
<constructor name= "int" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "from" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2020-11-09 16:46:03 +00:00
Constructs an [int] as a copy of the given [int].
2017-09-12 20:42:36 +00:00
</description>
2021-09-21 02:49:02 +00:00
</constructor>
2021-09-18 22:46:57 +00:00
<constructor name= "int" >
<return type= "int" />
<param index= "0" name= "from" type= "String" />
<description >
2022-12-14 06:40:50 +00:00
Constructs a new [int] from a [String], following the same rules as [method String.to_int].
2021-09-18 22:46:57 +00:00
</description>
</constructor>
2021-09-21 02:49:02 +00:00
<constructor name= "int" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "from" type= "bool" />
2017-09-12 20:42:36 +00:00
<description >
2022-12-14 06:40:50 +00:00
Constructs a new [int] from a [bool]. [code]true[/code] is converted to [code]1[/code] and [code]false[/code] is converted to [code]0[/code].
2017-09-12 20:42:36 +00:00
</description>
2021-09-21 02:49:02 +00:00
</constructor>
<constructor name= "int" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "from" type= "float" />
2017-09-12 20:42:36 +00:00
<description >
2022-12-14 06:40:50 +00:00
Constructs a new [int] from a [float]. This will truncate the [float], discarding anything after the floating point.
2017-09-12 20:42:36 +00:00
</description>
2021-09-21 02:49:02 +00:00
</constructor>
</constructors>
<operators >
<operator name= "operator !=" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "float" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Returns [code]true[/code] if the [int] is not equivalent to the [float].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator !=" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Returns [code]true[/code] if the [int]s are not equal.
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator %" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Returns the remainder after dividing two [int]s. Uses truncated division, which returns a negative number if the dividend is negative. If this is not desired, consider using [method @GlobalScope.posmod].
2021-01-06 00:13:11 +00:00
[codeblock]
2022-12-14 06:40:50 +00:00
print(6 % 2) # Prints 0
print(11 % 4) # Prints 3
print(-5 % 3) # Prints -2
2021-01-06 00:13:11 +00:00
[/codeblock]
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator &" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Performs the bitwise [code]AND[/code] operation.
2021-01-06 00:13:11 +00:00
[codeblock]
2022-12-14 06:40:50 +00:00
print(0b1100 & 0b1010) # Prints 8 (binary 1000)
2021-01-06 00:13:11 +00:00
[/codeblock]
2022-12-14 06:40:50 +00:00
This is useful for retrieving binary flags from a variable.
2021-01-06 00:13:11 +00:00
[codeblock]
2022-12-14 06:40:50 +00:00
var flags = 0b101
# Check if the first or second bit are enabled.
if flags & 0b011:
do_stuff() # This line will run.
2021-01-06 00:13:11 +00:00
[/codeblock]
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator *" >
<return type= "Color" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "Color" />
2021-09-21 02:49:02 +00:00
<description >
2022-12-14 06:40:50 +00:00
Multiplies each component of the [Color] by the [int].
2021-09-21 02:49:02 +00:00
</description>
</operator>
<operator name= "operator *" >
<return type= "Quaternion" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "Quaternion" />
2021-09-21 02:49:02 +00:00
<description >
2022-12-14 06:40:50 +00:00
Multiplies each component of the [Quaternion] by the [int]. This operation is not meaningful on its own, but it can be used as a part of a larger expression.
2021-09-21 02:49:02 +00:00
</description>
</operator>
<operator name= "operator *" >
2021-07-30 13:28:05 +00:00
<return type= "Vector2" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "Vector2" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Multiplies each component of the [Vector2] by the [int].
2021-01-06 00:13:11 +00:00
[codeblock]
2022-12-14 06:40:50 +00:00
print(2 * Vector2(1, 4)) # Prints (2, 8)
2021-01-06 00:13:11 +00:00
[/codeblock]
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator *" >
2021-07-30 13:28:05 +00:00
<return type= "Vector2i" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "Vector2i" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Multiplies each component of the [Vector2i] by the [int].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator *" >
2021-07-30 13:28:05 +00:00
<return type= "Vector3" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "Vector3" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Multiplies each component of the [Vector3] by the [int].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator *" >
2021-07-30 13:28:05 +00:00
<return type= "Vector3i" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "Vector3i" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Multiplies each component of the [Vector3i] by the [int].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-19 23:11:13 +00:00
<operator name= "operator *" >
<return type= "Vector4" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "Vector4" />
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-19 23:11:13 +00:00
<description >
2022-12-14 06:40:50 +00:00
Multiplies each component of the [Vector4] by the [int].
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-19 23:11:13 +00:00
</description>
</operator>
<operator name= "operator *" >
<return type= "Vector4i" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "Vector4i" />
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-19 23:11:13 +00:00
<description >
2022-12-14 06:40:50 +00:00
Multiplies each component of the [Vector4i] by the [int].
Implement Vector4, Vector4i, Projection
Implement built-in classes Vector4, Vector4i and Projection.
* Two versions of Vector4 (float and integer).
* A Projection class, which is a 4x4 matrix specialized in projection types.
These types have been requested for a long time, but given they were very corner case they were not added before.
Because in Godot 4, reimplementing parts of the rendering engine is now possible, access to these types (heavily used by the rendering code) becomes a necessity.
**Q**: Why Projection and not Matrix4?
**A**: Godot does not use Matrix2, Matrix3, Matrix4x3, etc. naming convention because, within the engine, these types always have a *purpose*. As such, Godot names them: Transform2D, Transform3D or Basis. In this case, this 4x4 matrix is _always_ used as a _Projection_, hence the naming.
2022-07-19 23:11:13 +00:00
</description>
</operator>
2021-11-28 08:48:57 +00:00
<operator name= "operator *" >
<return type= "float" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "float" />
2021-11-28 08:48:57 +00:00
<description >
2022-12-14 06:40:50 +00:00
Multiplies the [float] by the [int]. The result is a [float].
2021-11-28 08:48:57 +00:00
</description>
</operator>
<operator name= "operator *" >
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2021-11-28 08:48:57 +00:00
<description >
2022-12-14 06:40:50 +00:00
Multiplies the two [int]s.
2021-11-28 08:48:57 +00:00
</description>
</operator>
2022-03-07 17:25:21 +00:00
<operator name= "operator **" >
<return type= "float" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "float" />
2022-03-07 17:25:21 +00:00
<description >
2022-10-30 12:23:41 +00:00
Raises an [int] to a power of a [float]. The result is a [float].
[codeblock]
2022-12-14 06:40:50 +00:00
print(2 ** 0.5) # Prints 1.4142135623731
2022-10-30 12:23:41 +00:00
[/codeblock]
2022-03-07 17:25:21 +00:00
</description>
</operator>
<operator name= "operator **" >
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2022-03-07 17:25:21 +00:00
<description >
2022-12-14 06:40:50 +00:00
Raises the left [int] to a power of the right [int].
2022-10-30 12:23:41 +00:00
[codeblock]
2022-12-14 06:40:50 +00:00
print(3 ** 4) # Prints 81
2022-10-30 12:23:41 +00:00
[/codeblock]
2022-03-07 17:25:21 +00:00
</description>
</operator>
2021-09-21 02:49:02 +00:00
<operator name= "operator +" >
<return type= "float" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "float" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Adds the [int] and the [float]. The result is a [float].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator +" >
2021-09-17 15:22:48 +00:00
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Adds the two [int]s.
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator -" >
2021-07-30 13:28:05 +00:00
<return type= "float" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "float" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Subtracts the [float] from the [int]. The result is a [float].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator -" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Subtracts the two [int]s.
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator /" >
2021-07-30 13:28:05 +00:00
<return type= "float" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "float" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Divides the [int] by the [float]. The result is a [float].
2021-01-06 00:13:11 +00:00
[codeblock]
2022-12-14 06:40:50 +00:00
print(10 / 3.0) # Prints 3.33333333333333
2021-01-06 00:13:11 +00:00
[/codeblock]
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator /" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Divides the two [int]s. The result is an [int]. This will truncate the [float], discarding anything after the floating point.
2021-01-06 00:13:11 +00:00
[codeblock]
2022-12-14 06:40:50 +00:00
print(6 / 2) # Prints 3
print(5 / 3) # Prints 1
2021-01-06 00:13:11 +00:00
[/codeblock]
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator <" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "float" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Returns [code]true[/code] if the [int] is less than the [float].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator <" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Returns [code]true[/code] if the left [int] is less than the right [int].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator <<" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Performs the bitwise shift left operation. Effectively the same as multiplying by a power of 2.
2021-01-06 00:13:11 +00:00
[codeblock]
2022-12-14 06:40:50 +00:00
print(0b1010 < < 1) # Prints 20 (binary 10100)
print(0b1010 < < 3) # Prints 80 (binary 1010000)
2021-01-06 00:13:11 +00:00
[/codeblock]
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator <=" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "float" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Returns [code]true[/code] if the [int] is less than or equal to the [float].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator <=" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Returns [code]true[/code] if the left [int] is less than or equal to the right [int].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator ==" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "float" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Returns [code]true[/code] if the [int] is equal to the [float].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator ==" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Returns [code]true[/code] if the two [int]s are equal.
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator >" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "float" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Returns [code]true[/code] if the [int] is greater than the [float].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator >" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Returns [code]true[/code] if the left [int] is greater than the right [int].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator >=" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "float" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Returns [code]true[/code] if the [int] is greater than or equal to the [float].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator >=" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Returns [code]true[/code] if the left [int] is greater than or equal to the right [int].
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator >>" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Performs the bitwise shift right operation. Effectively the same as dividing by a power of 2.
2021-01-06 00:13:11 +00:00
[codeblock]
2022-12-14 06:40:50 +00:00
print(0b1010 > > 1) # Prints 5 (binary 101)
print(0b1010 > > 2) # Prints 2 (binary 10)
2021-01-06 00:13:11 +00:00
[/codeblock]
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator ^" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Performs the bitwise [code]XOR[/code] operation.
2021-01-06 00:13:11 +00:00
[codeblock]
2022-12-14 06:40:50 +00:00
print(0b1100 ^ 0b1010) # Prints 6 (binary 110)
2021-01-06 00:13:11 +00:00
[/codeblock]
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator unary+" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2021-06-19 15:58:49 +00:00
<description >
2021-08-18 18:04:10 +00:00
Returns the same value as if the [code]+[/code] was not there. Unary [code]+[/code] does nothing, but sometimes it can make your code more readable.
2021-06-19 15:58:49 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator unary-" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2021-06-19 15:58:49 +00:00
<description >
2021-08-18 18:04:10 +00:00
Returns the negated value of the [int]. If positive, turns the number negative. If negative, turns the number positive. If zero, does nothing.
2021-06-19 15:58:49 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator |" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "right" type= "int" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Performs the bitwise [code]OR[/code] operation.
2021-01-06 00:13:11 +00:00
[codeblock]
2022-12-14 06:40:50 +00:00
print(0b1100 | 0b1010) # Prints 14 (binary 1110)
2021-01-06 00:13:11 +00:00
[/codeblock]
2022-12-14 06:40:50 +00:00
This is useful for storing binary flags in a variable.
2021-01-06 00:13:11 +00:00
[codeblock]
var flags = 0
2022-12-14 06:40:50 +00:00
flags |= 0b101 # Turn the first and third bits on.
2021-01-06 00:13:11 +00:00
[/codeblock]
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
<operator name= "operator ~" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2020-11-10 13:16:20 +00:00
<description >
2022-12-14 06:40:50 +00:00
Performs the bitwise [code]NOT[/code] operation on the [int]. Due to [url=https://en.wikipedia.org/wiki/Two%27s_complement/]2's complement[/url], it's effectively equal to [code]-(int + 1)[/code].
2021-01-06 00:13:11 +00:00
[codeblock]
2022-12-14 06:40:50 +00:00
print(~4) # Prints -5
print(~(-7)) # Prints 6
2021-01-06 00:13:11 +00:00
[/codeblock]
2020-11-10 13:16:20 +00:00
</description>
2021-09-21 02:49:02 +00:00
</operator>
</operators>
2017-09-12 20:42:36 +00:00
</class>