class_int.rst 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/int.xml.
  6. .. _class_int:
  7. int
  8. ===
  9. Integer built-in type.
  10. Description
  11. -----------
  12. Signed 64-bit integer type.
  13. It can take values in the interval ``[-2^63, 2^63 - 1]``, i.e. ``[-9223372036854775808, 9223372036854775807]``. Exceeding those bounds will wrap around.
  14. \ ``int`` is a :ref:`Variant<class_Variant>` type, and will thus be used when assigning an integer value to a :ref:`Variant<class_Variant>`. It can also be enforced with the ``: int`` type hint.
  15. .. tabs::
  16. .. code-tab:: gdscript
  17. var my_variant = 0 # int, value 0.
  18. my_variant += 4.2 # float, value 4.2.
  19. var my_int: int = 1 # int, value 1.
  20. my_int = 4.2 # int, value 4, the right value is implicitly cast to int.
  21. my_int = int("6.7") # int, value 6, the String is explicitly cast with int.
  22. var max_int = 9223372036854775807
  23. print(max_int) # 9223372036854775807, OK.
  24. max_int += 1
  25. print(max_int) # -9223372036854775808, we overflowed and wrapped around.
  26. .. code-tab:: csharp
  27. int myInt = (int)"6.7".ToFloat(); // int, value 6, the String is explicitly cast with int.
  28. // We have to use `long` here, because GDSript's `int`
  29. // is 64 bits long while C#'s `int` is only 32 bits.
  30. long maxInt = 9223372036854775807;
  31. GD.Print(maxInt); // 9223372036854775807, OK.
  32. maxInt++;
  33. GD.Print(maxInt); // -9223372036854775808, we overflowed and wrapped around.
  34. // Alternatively, if we used C#'s 32-bit `int` type, the maximum value is much smaller:
  35. int halfInt = 2147483647;
  36. GD.Print(halfInt); // 2147483647, OK.
  37. halfInt++;
  38. GD.Print(halfInt); // -2147483648, we overflowed and wrapped around.
  39. Constructors
  40. ------------
  41. +-----------------------+----------------------------------------------------------------------------------+
  42. | :ref:`int<class_int>` | :ref:`int<class_int_constructor_int>` **(** **)** |
  43. +-----------------------+----------------------------------------------------------------------------------+
  44. | :ref:`int<class_int>` | :ref:`int<class_int_constructor_int>` **(** :ref:`int<class_int>` from **)** |
  45. +-----------------------+----------------------------------------------------------------------------------+
  46. | :ref:`int<class_int>` | :ref:`int<class_int_constructor_int>` **(** :ref:`bool<class_bool>` from **)** |
  47. +-----------------------+----------------------------------------------------------------------------------+
  48. | :ref:`int<class_int>` | :ref:`int<class_int_constructor_int>` **(** :ref:`float<class_float>` from **)** |
  49. +-----------------------+----------------------------------------------------------------------------------+
  50. Operators
  51. ---------
  52. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  53. | :ref:`bool<class_bool>` | :ref:`operator !=<class_int_operator_neq_bool>` **(** :ref:`float<class_float>` right **)** |
  54. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  55. | :ref:`bool<class_bool>` | :ref:`operator !=<class_int_operator_neq_bool>` **(** :ref:`int<class_int>` right **)** |
  56. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  57. | :ref:`int<class_int>` | :ref:`operator %<class_int_operator_mod_int>` **(** :ref:`int<class_int>` right **)** |
  58. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  59. | :ref:`int<class_int>` | :ref:`operator &<class_int_operator_bwand_int>` **(** :ref:`int<class_int>` right **)** |
  60. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  61. | :ref:`Color<class_Color>` | :ref:`operator *<class_int_operator_mul_Color>` **(** :ref:`Color<class_Color>` right **)** |
  62. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  63. | :ref:`Quaternion<class_Quaternion>` | :ref:`operator *<class_int_operator_mul_Quaternion>` **(** :ref:`Quaternion<class_Quaternion>` right **)** |
  64. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  65. | :ref:`Vector2<class_Vector2>` | :ref:`operator *<class_int_operator_mul_Vector2>` **(** :ref:`Vector2<class_Vector2>` right **)** |
  66. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  67. | :ref:`Vector2i<class_Vector2i>` | :ref:`operator *<class_int_operator_mul_Vector2i>` **(** :ref:`Vector2i<class_Vector2i>` right **)** |
  68. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  69. | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_int_operator_mul_Vector3>` **(** :ref:`Vector3<class_Vector3>` right **)** |
  70. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  71. | :ref:`Vector3i<class_Vector3i>` | :ref:`operator *<class_int_operator_mul_Vector3i>` **(** :ref:`Vector3i<class_Vector3i>` right **)** |
  72. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  73. | :ref:`Vector4<class_Vector4>` | :ref:`operator *<class_int_operator_mul_Vector4>` **(** :ref:`Vector4<class_Vector4>` right **)** |
  74. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  75. | :ref:`Vector4i<class_Vector4i>` | :ref:`operator *<class_int_operator_mul_Vector4i>` **(** :ref:`Vector4i<class_Vector4i>` right **)** |
  76. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  77. | :ref:`float<class_float>` | :ref:`operator *<class_int_operator_mul_float>` **(** :ref:`float<class_float>` right **)** |
  78. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  79. | :ref:`int<class_int>` | :ref:`operator *<class_int_operator_mul_int>` **(** :ref:`int<class_int>` right **)** |
  80. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  81. | :ref:`float<class_float>` | :ref:`operator **<class_int_operator_pow_float>` **(** :ref:`float<class_float>` right **)** |
  82. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  83. | :ref:`int<class_int>` | :ref:`operator **<class_int_operator_pow_int>` **(** :ref:`int<class_int>` right **)** |
  84. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  85. | :ref:`float<class_float>` | :ref:`operator +<class_int_operator_sum_float>` **(** :ref:`float<class_float>` right **)** |
  86. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  87. | :ref:`int<class_int>` | :ref:`operator +<class_int_operator_sum_int>` **(** :ref:`int<class_int>` right **)** |
  88. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  89. | :ref:`float<class_float>` | :ref:`operator -<class_int_operator_dif_float>` **(** :ref:`float<class_float>` right **)** |
  90. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  91. | :ref:`int<class_int>` | :ref:`operator -<class_int_operator_dif_int>` **(** :ref:`int<class_int>` right **)** |
  92. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  93. | :ref:`float<class_float>` | :ref:`operator /<class_int_operator_div_float>` **(** :ref:`float<class_float>` right **)** |
  94. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  95. | :ref:`int<class_int>` | :ref:`operator /<class_int_operator_div_int>` **(** :ref:`int<class_int>` right **)** |
  96. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  97. | :ref:`bool<class_bool>` | :ref:`operator \<<class_int_operator_lt_bool>` **(** :ref:`float<class_float>` right **)** |
  98. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  99. | :ref:`bool<class_bool>` | :ref:`operator \<<class_int_operator_lt_bool>` **(** :ref:`int<class_int>` right **)** |
  100. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  101. | :ref:`int<class_int>` | :ref:`operator \<\<<class_int_operator_bwsl_int>` **(** :ref:`int<class_int>` right **)** |
  102. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  103. | :ref:`bool<class_bool>` | :ref:`operator \<=<class_int_operator_lte_bool>` **(** :ref:`float<class_float>` right **)** |
  104. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  105. | :ref:`bool<class_bool>` | :ref:`operator \<=<class_int_operator_lte_bool>` **(** :ref:`int<class_int>` right **)** |
  106. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  107. | :ref:`bool<class_bool>` | :ref:`operator ==<class_int_operator_eq_bool>` **(** :ref:`float<class_float>` right **)** |
  108. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  109. | :ref:`bool<class_bool>` | :ref:`operator ==<class_int_operator_eq_bool>` **(** :ref:`int<class_int>` right **)** |
  110. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  111. | :ref:`bool<class_bool>` | :ref:`operator ><class_int_operator_gt_bool>` **(** :ref:`float<class_float>` right **)** |
  112. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  113. | :ref:`bool<class_bool>` | :ref:`operator ><class_int_operator_gt_bool>` **(** :ref:`int<class_int>` right **)** |
  114. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  115. | :ref:`bool<class_bool>` | :ref:`operator >=<class_int_operator_gte_bool>` **(** :ref:`float<class_float>` right **)** |
  116. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  117. | :ref:`bool<class_bool>` | :ref:`operator >=<class_int_operator_gte_bool>` **(** :ref:`int<class_int>` right **)** |
  118. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  119. | :ref:`int<class_int>` | :ref:`operator >><class_int_operator_bwsr_int>` **(** :ref:`int<class_int>` right **)** |
  120. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  121. | :ref:`int<class_int>` | :ref:`operator ^<class_int_operator_bwxor_int>` **(** :ref:`int<class_int>` right **)** |
  122. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  123. | :ref:`int<class_int>` | :ref:`operator unary+<class_int_operator_unplus_int>` **(** **)** |
  124. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  125. | :ref:`int<class_int>` | :ref:`operator unary-<class_int_operator_unminus_int>` **(** **)** |
  126. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  127. | :ref:`int<class_int>` | :ref:`operator |<class_int_operator_bwor_int>` **(** :ref:`int<class_int>` right **)** |
  128. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  129. | :ref:`int<class_int>` | :ref:`operator ~<class_int_operator_bwnot_int>` **(** **)** |
  130. +-------------------------------------+------------------------------------------------------------------------------------------------------------+
  131. Constructor Descriptions
  132. ------------------------
  133. .. _class_int_constructor_int:
  134. - :ref:`int<class_int>` **int** **(** **)**
  135. Constructs a default-initialized ``int`` set to ``0``.
  136. ----
  137. - :ref:`int<class_int>` **int** **(** :ref:`int<class_int>` from **)**
  138. Constructs an ``int`` as a copy of the given ``int``.
  139. ----
  140. - :ref:`int<class_int>` **int** **(** :ref:`bool<class_bool>` from **)**
  141. Cast a :ref:`bool<class_bool>` value to an integer value, ``int(true)`` will be equals to 1 and ``int(false)`` will be equals to 0.
  142. ----
  143. - :ref:`int<class_int>` **int** **(** :ref:`float<class_float>` from **)**
  144. Cast a float value to an integer value, this method simply removes the number fractions (i.e. rounds ``from`` towards zero), so for example ``int(2.7)`` will be equals to 2, ``int(0.1)`` will be equals to 0 and ``int(-2.7)`` will be equals to -2. This operation is also called truncation.
  145. Operator Descriptions
  146. ---------------------
  147. .. _class_int_operator_neq_bool:
  148. - :ref:`bool<class_bool>` **operator !=** **(** :ref:`float<class_float>` right **)**
  149. Returns ``true`` if this ``int`` is not equivalent to the given :ref:`float<class_float>`.
  150. ----
  151. - :ref:`bool<class_bool>` **operator !=** **(** :ref:`int<class_int>` right **)**
  152. Returns ``true`` if the integers are not equal.
  153. ----
  154. .. _class_int_operator_mod_int:
  155. - :ref:`int<class_int>` **operator %** **(** :ref:`int<class_int>` right **)**
  156. Returns the remainder after dividing two integers. This operation uses truncated division, which is often not desired as it does not work well with negative numbers. Consider using :ref:`@GlobalScope.posmod<class_@GlobalScope_method_posmod>` instead if you want to handle negative numbers.
  157. ::
  158. print(5 % 2) # 1
  159. print(12 % 4) # 0
  160. print(-5 % 3) # -2
  161. ----
  162. .. _class_int_operator_bwand_int:
  163. - :ref:`int<class_int>` **operator &** **(** :ref:`int<class_int>` right **)**
  164. Returns the result of bitwise ``AND`` operation for two integers.
  165. ::
  166. print(3 & 1) # 1
  167. print(11 & 3) # 3
  168. It's useful to retrieve binary flags from a variable.
  169. ::
  170. var flags = 5
  171. # Do something if the first bit is enabled.
  172. if flags & 1:
  173. do_stuff()
  174. ----
  175. .. _class_int_operator_mul_Color:
  176. - :ref:`Color<class_Color>` **operator *** **(** :ref:`Color<class_Color>` right **)**
  177. Multiplies each component of the :ref:`Color<class_Color>` by the given ``int``.
  178. ----
  179. - :ref:`Quaternion<class_Quaternion>` **operator *** **(** :ref:`Quaternion<class_Quaternion>` right **)**
  180. Multiplies each component of the :ref:`Quaternion<class_Quaternion>` by the given ``int``. This operation is not meaningful on its own, but it can be used as a part of a larger expression.
  181. ----
  182. - :ref:`Vector2<class_Vector2>` **operator *** **(** :ref:`Vector2<class_Vector2>` right **)**
  183. Multiplies each component of the :ref:`Vector2<class_Vector2>` by the given ``int``.
  184. ::
  185. print(2 * Vector2(1, 1)) # Vector2(2, 2)
  186. ----
  187. - :ref:`Vector2i<class_Vector2i>` **operator *** **(** :ref:`Vector2i<class_Vector2i>` right **)**
  188. Multiplies each component of the :ref:`Vector2i<class_Vector2i>` by the given ``int``.
  189. ----
  190. - :ref:`Vector3<class_Vector3>` **operator *** **(** :ref:`Vector3<class_Vector3>` right **)**
  191. Multiplies each component of the :ref:`Vector3<class_Vector3>` by the given ``int``.
  192. ----
  193. - :ref:`Vector3i<class_Vector3i>` **operator *** **(** :ref:`Vector3i<class_Vector3i>` right **)**
  194. Multiplies each component of the :ref:`Vector3i<class_Vector3i>` by the given ``int``.
  195. ----
  196. - :ref:`Vector4<class_Vector4>` **operator *** **(** :ref:`Vector4<class_Vector4>` right **)**
  197. Multiplies each component of the :ref:`Vector4<class_Vector4>` by the given ``int``.
  198. ----
  199. - :ref:`Vector4i<class_Vector4i>` **operator *** **(** :ref:`Vector4i<class_Vector4i>` right **)**
  200. Multiplies each component of the :ref:`Vector4i<class_Vector4i>` by the given ``int``.
  201. ----
  202. - :ref:`float<class_float>` **operator *** **(** :ref:`float<class_float>` right **)**
  203. Multiplies an ``int`` and a :ref:`float<class_float>`. The result is a :ref:`float<class_float>`.
  204. ----
  205. - :ref:`int<class_int>` **operator *** **(** :ref:`int<class_int>` right **)**
  206. Multiplies two ``int``\ s.
  207. ----
  208. .. _class_int_operator_pow_float:
  209. - :ref:`float<class_float>` **operator **** **(** :ref:`float<class_float>` right **)**
  210. Raises an ``int`` to a power of a :ref:`float<class_float>`. The result is a :ref:`float<class_float>`.
  211. ::
  212. print(8**0.25) # 1.68179283050743
  213. ----
  214. - :ref:`int<class_int>` **operator **** **(** :ref:`int<class_int>` right **)**
  215. Raises an ``int`` to a power of a ``int``.
  216. ::
  217. print(5**5) # 3125
  218. ----
  219. .. _class_int_operator_sum_float:
  220. - :ref:`float<class_float>` **operator +** **(** :ref:`float<class_float>` right **)**
  221. Adds an ``int`` and a :ref:`float<class_float>`. The result is a :ref:`float<class_float>`.
  222. ----
  223. - :ref:`int<class_int>` **operator +** **(** :ref:`int<class_int>` right **)**
  224. Adds two integers.
  225. ----
  226. .. _class_int_operator_dif_float:
  227. - :ref:`float<class_float>` **operator -** **(** :ref:`float<class_float>` right **)**
  228. Subtracts a :ref:`float<class_float>` from an ``int``. The result is a :ref:`float<class_float>`.
  229. ----
  230. - :ref:`int<class_int>` **operator -** **(** :ref:`int<class_int>` right **)**
  231. Subtracts two integers.
  232. ----
  233. .. _class_int_operator_div_float:
  234. - :ref:`float<class_float>` **operator /** **(** :ref:`float<class_float>` right **)**
  235. Divides an ``int`` by a :ref:`float<class_float>`. The result is a :ref:`float<class_float>`.
  236. ::
  237. print(10 / 3.0) # 3.333...
  238. ----
  239. - :ref:`int<class_int>` **operator /** **(** :ref:`int<class_int>` right **)**
  240. Divides two integers. The decimal part of the result is discarded (truncated).
  241. ::
  242. print(10 / 2) # 5
  243. print(10 / 3) # 3
  244. ----
  245. .. _class_int_operator_lt_bool:
  246. - :ref:`bool<class_bool>` **operator <** **(** :ref:`float<class_float>` right **)**
  247. Returns ``true`` if this ``int`` is less than the given :ref:`float<class_float>`.
  248. ----
  249. - :ref:`bool<class_bool>` **operator <** **(** :ref:`int<class_int>` right **)**
  250. Returns ``true`` if the left integer is less than the right one.
  251. ----
  252. .. _class_int_operator_bwsl_int:
  253. - :ref:`int<class_int>` **operator <<** **(** :ref:`int<class_int>` right **)**
  254. Performs bitwise shift left operation on the integer. Effectively the same as multiplying by a power of 2.
  255. ::
  256. print(10 << 1) # 20
  257. print(10 << 4) # 160
  258. ----
  259. .. _class_int_operator_lte_bool:
  260. - :ref:`bool<class_bool>` **operator <=** **(** :ref:`float<class_float>` right **)**
  261. Returns ``true`` if this ``int`` is less than or equal to the given :ref:`float<class_float>`.
  262. ----
  263. - :ref:`bool<class_bool>` **operator <=** **(** :ref:`int<class_int>` right **)**
  264. Returns ``true`` if the left integer is less than or equal to the right one.
  265. ----
  266. .. _class_int_operator_eq_bool:
  267. - :ref:`bool<class_bool>` **operator ==** **(** :ref:`float<class_float>` right **)**
  268. Returns ``true`` if the integer is equal to the given :ref:`float<class_float>`.
  269. ----
  270. - :ref:`bool<class_bool>` **operator ==** **(** :ref:`int<class_int>` right **)**
  271. Returns ``true`` if both integers are equal.
  272. ----
  273. .. _class_int_operator_gt_bool:
  274. - :ref:`bool<class_bool>` **operator >** **(** :ref:`float<class_float>` right **)**
  275. Returns ``true`` if this ``int`` is greater than the given :ref:`float<class_float>`.
  276. ----
  277. - :ref:`bool<class_bool>` **operator >** **(** :ref:`int<class_int>` right **)**
  278. Returns ``true`` if the left integer is greater than the right one.
  279. ----
  280. .. _class_int_operator_gte_bool:
  281. - :ref:`bool<class_bool>` **operator >=** **(** :ref:`float<class_float>` right **)**
  282. Returns ``true`` if this ``int`` is greater than or equal to the given :ref:`float<class_float>`.
  283. ----
  284. - :ref:`bool<class_bool>` **operator >=** **(** :ref:`int<class_int>` right **)**
  285. Returns ``true`` if the left integer is greater than or equal to the right one.
  286. ----
  287. .. _class_int_operator_bwsr_int:
  288. - :ref:`int<class_int>` **operator >>** **(** :ref:`int<class_int>` right **)**
  289. Performs bitwise shift right operation on the integer. Effectively the same as dividing by a power of 2.
  290. ::
  291. print(10 >> 1) # 5
  292. print(10 >> 2) # 2
  293. ----
  294. .. _class_int_operator_bwxor_int:
  295. - :ref:`int<class_int>` **operator ^** **(** :ref:`int<class_int>` right **)**
  296. Returns the result of bitwise ``XOR`` operation for two integers.
  297. ::
  298. print(5 ^ 1) # 4
  299. print(4 ^ 7) # 3
  300. ----
  301. .. _class_int_operator_unplus_int:
  302. - :ref:`int<class_int>` **operator unary+** **(** **)**
  303. Returns the same value as if the ``+`` was not there. Unary ``+`` does nothing, but sometimes it can make your code more readable.
  304. ----
  305. .. _class_int_operator_unminus_int:
  306. - :ref:`int<class_int>` **operator unary-** **(** **)**
  307. Returns the negated value of the ``int``. If positive, turns the number negative. If negative, turns the number positive. If zero, does nothing.
  308. ----
  309. .. _class_int_operator_bwor_int:
  310. - :ref:`int<class_int>` **operator |** **(** :ref:`int<class_int>` right **)**
  311. Returns the result of bitwise ``OR`` operation for two integers.
  312. ::
  313. print(2 | 4) # 6
  314. print(1 | 3) # 3
  315. It's useful to store binary flags in a variable.
  316. ::
  317. var flags = 0
  318. # Turn first and third bit on.
  319. flags |= 1
  320. flags |= 4
  321. ----
  322. .. _class_int_operator_bwnot_int:
  323. - :ref:`int<class_int>` **operator ~** **(** **)**
  324. Returns the result of bitwise ``NOT`` operation for the integer. It's effectively equal to ``-int + 1``.
  325. ::
  326. print(~4) # -3
  327. print(~7) # -6
  328. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  329. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  330. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  331. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  332. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  333. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`