class_float.rst 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  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/float.xml.
  6. .. _class_float:
  7. float
  8. =====
  9. A built-in type for floating-point numbers.
  10. .. rst-class:: classref-introduction-group
  11. Description
  12. -----------
  13. The **float** built-in type is a 64-bit double-precision floating-point number, equivalent to ``double`` in C++. This type has 14 reliable decimal digits of precision. The maximum value of **float** is approximately ``1.79769e308``, and the minimum is approximately ``-1.79769e308``.
  14. Many methods and properties in the engine use 32-bit single-precision floating-point numbers instead, equivalent to ``float`` in C++, which have 6 reliable decimal digits of precision. For data structures such as :ref:`Vector2<class_Vector2>` and :ref:`Vector3<class_Vector3>`, Godot uses 32-bit floating-point numbers by default, but it can be changed to use 64-bit doubles if Godot is compiled with the ``precision=double`` option.
  15. Math done using the **float** type is not guaranteed to be exact and will often result in small errors. You should usually use the :ref:`@GlobalScope.is_equal_approx<class_@GlobalScope_method_is_equal_approx>` and :ref:`@GlobalScope.is_zero_approx<class_@GlobalScope_method_is_zero_approx>` methods instead of ``==`` to compare **float** values for equality.
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - `Wikipedia: Double-precision floating-point format <https://en.wikipedia.org/wiki/Double-precision_floating-point_format>`__
  20. - `Wikipedia: Single-precision floating-point format <https://en.wikipedia.org/wiki/Single-precision_floating-point_format>`__
  21. .. rst-class:: classref-reftable-group
  22. Constructors
  23. ------------
  24. .. table::
  25. :widths: auto
  26. +---------------------------+---------------------------------------------------------------------------------------+
  27. | :ref:`float<class_float>` | :ref:`float<class_float_constructor_float>`\ (\ ) |
  28. +---------------------------+---------------------------------------------------------------------------------------+
  29. | :ref:`float<class_float>` | :ref:`float<class_float_constructor_float>`\ (\ from\: :ref:`float<class_float>`\ ) |
  30. +---------------------------+---------------------------------------------------------------------------------------+
  31. | :ref:`float<class_float>` | :ref:`float<class_float_constructor_float>`\ (\ from\: :ref:`String<class_String>`\ ) |
  32. +---------------------------+---------------------------------------------------------------------------------------+
  33. | :ref:`float<class_float>` | :ref:`float<class_float_constructor_float>`\ (\ from\: :ref:`bool<class_bool>`\ ) |
  34. +---------------------------+---------------------------------------------------------------------------------------+
  35. | :ref:`float<class_float>` | :ref:`float<class_float_constructor_float>`\ (\ from\: :ref:`int<class_int>`\ ) |
  36. +---------------------------+---------------------------------------------------------------------------------------+
  37. .. rst-class:: classref-reftable-group
  38. Operators
  39. ---------
  40. .. table::
  41. :widths: auto
  42. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`operator !=<class_float_operator_neq_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  44. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  45. | :ref:`bool<class_bool>` | :ref:`operator !=<class_float_operator_neq_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  46. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  47. | :ref:`Color<class_Color>` | :ref:`operator *<class_float_operator_mul_Color>`\ (\ right\: :ref:`Color<class_Color>`\ ) |
  48. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  49. | :ref:`Quaternion<class_Quaternion>` | :ref:`operator *<class_float_operator_mul_Quaternion>`\ (\ right\: :ref:`Quaternion<class_Quaternion>`\ ) |
  50. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  51. | :ref:`Vector2<class_Vector2>` | :ref:`operator *<class_float_operator_mul_Vector2>`\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) |
  52. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  53. | :ref:`Vector2<class_Vector2>` | :ref:`operator *<class_float_operator_mul_Vector2i>`\ (\ right\: :ref:`Vector2i<class_Vector2i>`\ ) |
  54. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  55. | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_float_operator_mul_Vector3>`\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) |
  56. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  57. | :ref:`Vector3<class_Vector3>` | :ref:`operator *<class_float_operator_mul_Vector3i>`\ (\ right\: :ref:`Vector3i<class_Vector3i>`\ ) |
  58. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  59. | :ref:`Vector4<class_Vector4>` | :ref:`operator *<class_float_operator_mul_Vector4>`\ (\ right\: :ref:`Vector4<class_Vector4>`\ ) |
  60. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  61. | :ref:`Vector4<class_Vector4>` | :ref:`operator *<class_float_operator_mul_Vector4i>`\ (\ right\: :ref:`Vector4i<class_Vector4i>`\ ) |
  62. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  63. | :ref:`float<class_float>` | :ref:`operator *<class_float_operator_mul_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  64. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  65. | :ref:`float<class_float>` | :ref:`operator *<class_float_operator_mul_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  66. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  67. | :ref:`float<class_float>` | :ref:`operator **<class_float_operator_pow_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  68. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  69. | :ref:`float<class_float>` | :ref:`operator **<class_float_operator_pow_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  70. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  71. | :ref:`float<class_float>` | :ref:`operator +<class_float_operator_sum_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  72. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  73. | :ref:`float<class_float>` | :ref:`operator +<class_float_operator_sum_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  74. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  75. | :ref:`float<class_float>` | :ref:`operator -<class_float_operator_dif_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  76. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  77. | :ref:`float<class_float>` | :ref:`operator -<class_float_operator_dif_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  78. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  79. | :ref:`float<class_float>` | :ref:`operator /<class_float_operator_div_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  80. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  81. | :ref:`float<class_float>` | :ref:`operator /<class_float_operator_div_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  82. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  83. | :ref:`bool<class_bool>` | :ref:`operator \<<class_float_operator_lt_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  84. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  85. | :ref:`bool<class_bool>` | :ref:`operator \<<class_float_operator_lt_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  86. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  87. | :ref:`bool<class_bool>` | :ref:`operator \<=<class_float_operator_lte_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  88. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  89. | :ref:`bool<class_bool>` | :ref:`operator \<=<class_float_operator_lte_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  90. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  91. | :ref:`bool<class_bool>` | :ref:`operator ==<class_float_operator_eq_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  92. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  93. | :ref:`bool<class_bool>` | :ref:`operator ==<class_float_operator_eq_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  94. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  95. | :ref:`bool<class_bool>` | :ref:`operator ><class_float_operator_gt_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  96. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  97. | :ref:`bool<class_bool>` | :ref:`operator ><class_float_operator_gt_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  98. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  99. | :ref:`bool<class_bool>` | :ref:`operator >=<class_float_operator_gte_float>`\ (\ right\: :ref:`float<class_float>`\ ) |
  100. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  101. | :ref:`bool<class_bool>` | :ref:`operator >=<class_float_operator_gte_int>`\ (\ right\: :ref:`int<class_int>`\ ) |
  102. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  103. | :ref:`float<class_float>` | :ref:`operator unary+<class_float_operator_unplus>`\ (\ ) |
  104. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  105. | :ref:`float<class_float>` | :ref:`operator unary-<class_float_operator_unminus>`\ (\ ) |
  106. +-------------------------------------+-----------------------------------------------------------------------------------------------------------+
  107. .. rst-class:: classref-section-separator
  108. ----
  109. .. rst-class:: classref-descriptions-group
  110. Constructor Descriptions
  111. ------------------------
  112. .. _class_float_constructor_float:
  113. .. rst-class:: classref-constructor
  114. :ref:`float<class_float>` **float**\ (\ ) :ref:`๐Ÿ”—<class_float_constructor_float>`
  115. Constructs a default-initialized **float** set to ``0.0``.
  116. .. rst-class:: classref-item-separator
  117. ----
  118. .. rst-class:: classref-constructor
  119. :ref:`float<class_float>` **float**\ (\ from\: :ref:`float<class_float>`\ )
  120. Constructs a **float** as a copy of the given **float**.
  121. .. rst-class:: classref-item-separator
  122. ----
  123. .. rst-class:: classref-constructor
  124. :ref:`float<class_float>` **float**\ (\ from\: :ref:`String<class_String>`\ )
  125. Converts a :ref:`String<class_String>` to a **float**, following the same rules as :ref:`String.to_float<class_String_method_to_float>`.
  126. .. rst-class:: classref-item-separator
  127. ----
  128. .. rst-class:: classref-constructor
  129. :ref:`float<class_float>` **float**\ (\ from\: :ref:`bool<class_bool>`\ )
  130. Cast a :ref:`bool<class_bool>` value to a floating-point value, ``float(true)`` will be equal to 1.0 and ``float(false)`` will be equal to 0.0.
  131. .. rst-class:: classref-item-separator
  132. ----
  133. .. rst-class:: classref-constructor
  134. :ref:`float<class_float>` **float**\ (\ from\: :ref:`int<class_int>`\ )
  135. Cast an :ref:`int<class_int>` value to a floating-point value, ``float(1)`` will be equal to ``1.0``.
  136. .. rst-class:: classref-section-separator
  137. ----
  138. .. rst-class:: classref-descriptions-group
  139. Operator Descriptions
  140. ---------------------
  141. .. _class_float_operator_neq_float:
  142. .. rst-class:: classref-operator
  143. :ref:`bool<class_bool>` **operator !=**\ (\ right\: :ref:`float<class_float>`\ ) :ref:`๐Ÿ”—<class_float_operator_neq_float>`
  144. Returns ``true`` if two floats are different from each other.
  145. \ **Note:** :ref:`@GDScript.NAN<class_@GDScript_constant_NAN>` doesn't behave the same as other numbers. Therefore, the results from this operator may not be accurate if NaNs are included.
  146. .. rst-class:: classref-item-separator
  147. ----
  148. .. _class_float_operator_neq_int:
  149. .. rst-class:: classref-operator
  150. :ref:`bool<class_bool>` **operator !=**\ (\ right\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_float_operator_neq_int>`
  151. Returns ``true`` if the integer has different value than the float.
  152. .. rst-class:: classref-item-separator
  153. ----
  154. .. _class_float_operator_mul_Color:
  155. .. rst-class:: classref-operator
  156. :ref:`Color<class_Color>` **operator ***\ (\ right\: :ref:`Color<class_Color>`\ ) :ref:`๐Ÿ”—<class_float_operator_mul_Color>`
  157. Multiplies each component of the :ref:`Color<class_Color>`, including the alpha, by the given **float**.
  158. ::
  159. print(1.5 * Color(0.5, 0.5, 0.5)) # Prints "(0.75, 0.75, 0.75, 1.5)"
  160. .. rst-class:: classref-item-separator
  161. ----
  162. .. _class_float_operator_mul_Quaternion:
  163. .. rst-class:: classref-operator
  164. :ref:`Quaternion<class_Quaternion>` **operator ***\ (\ right\: :ref:`Quaternion<class_Quaternion>`\ ) :ref:`๐Ÿ”—<class_float_operator_mul_Quaternion>`
  165. Multiplies each component of the :ref:`Quaternion<class_Quaternion>` by the given **float**. This operation is not meaningful on its own, but it can be used as a part of a larger expression.
  166. .. rst-class:: classref-item-separator
  167. ----
  168. .. _class_float_operator_mul_Vector2:
  169. .. rst-class:: classref-operator
  170. :ref:`Vector2<class_Vector2>` **operator ***\ (\ right\: :ref:`Vector2<class_Vector2>`\ ) :ref:`๐Ÿ”—<class_float_operator_mul_Vector2>`
  171. Multiplies each component of the :ref:`Vector2<class_Vector2>` by the given **float**.
  172. ::
  173. print(2.5 * Vector2(1, 3)) # Prints "(2.5, 7.5)"
  174. .. rst-class:: classref-item-separator
  175. ----
  176. .. _class_float_operator_mul_Vector2i:
  177. .. rst-class:: classref-operator
  178. :ref:`Vector2<class_Vector2>` **operator ***\ (\ right\: :ref:`Vector2i<class_Vector2i>`\ ) :ref:`๐Ÿ”—<class_float_operator_mul_Vector2i>`
  179. Multiplies each component of the :ref:`Vector2i<class_Vector2i>` by the given **float**. Returns a :ref:`Vector2<class_Vector2>`.
  180. ::
  181. print(0.9 * Vector2i(10, 15)) # Prints "(9, 13.5)"
  182. .. rst-class:: classref-item-separator
  183. ----
  184. .. _class_float_operator_mul_Vector3:
  185. .. rst-class:: classref-operator
  186. :ref:`Vector3<class_Vector3>` **operator ***\ (\ right\: :ref:`Vector3<class_Vector3>`\ ) :ref:`๐Ÿ”—<class_float_operator_mul_Vector3>`
  187. Multiplies each component of the :ref:`Vector3<class_Vector3>` by the given **float**.
  188. .. rst-class:: classref-item-separator
  189. ----
  190. .. _class_float_operator_mul_Vector3i:
  191. .. rst-class:: classref-operator
  192. :ref:`Vector3<class_Vector3>` **operator ***\ (\ right\: :ref:`Vector3i<class_Vector3i>`\ ) :ref:`๐Ÿ”—<class_float_operator_mul_Vector3i>`
  193. Multiplies each component of the :ref:`Vector3i<class_Vector3i>` by the given **float**. Returns a :ref:`Vector3<class_Vector3>`.
  194. ::
  195. print(0.9 * Vector3i(10, 15, 20)) # Prints "(9, 13.5, 18)"
  196. .. rst-class:: classref-item-separator
  197. ----
  198. .. _class_float_operator_mul_Vector4:
  199. .. rst-class:: classref-operator
  200. :ref:`Vector4<class_Vector4>` **operator ***\ (\ right\: :ref:`Vector4<class_Vector4>`\ ) :ref:`๐Ÿ”—<class_float_operator_mul_Vector4>`
  201. Multiplies each component of the :ref:`Vector4<class_Vector4>` by the given **float**.
  202. .. rst-class:: classref-item-separator
  203. ----
  204. .. _class_float_operator_mul_Vector4i:
  205. .. rst-class:: classref-operator
  206. :ref:`Vector4<class_Vector4>` **operator ***\ (\ right\: :ref:`Vector4i<class_Vector4i>`\ ) :ref:`๐Ÿ”—<class_float_operator_mul_Vector4i>`
  207. Multiplies each component of the :ref:`Vector4i<class_Vector4i>` by the given **float**. Returns a :ref:`Vector4<class_Vector4>`.
  208. ::
  209. print(0.9 * Vector4i(10, 15, 20, -10)) # Prints "(9, 13.5, 18, -9)"
  210. .. rst-class:: classref-item-separator
  211. ----
  212. .. _class_float_operator_mul_float:
  213. .. rst-class:: classref-operator
  214. :ref:`float<class_float>` **operator ***\ (\ right\: :ref:`float<class_float>`\ ) :ref:`๐Ÿ”—<class_float_operator_mul_float>`
  215. Multiplies two **float**\ s.
  216. .. rst-class:: classref-item-separator
  217. ----
  218. .. _class_float_operator_mul_int:
  219. .. rst-class:: classref-operator
  220. :ref:`float<class_float>` **operator ***\ (\ right\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_float_operator_mul_int>`
  221. Multiplies a **float** and an :ref:`int<class_int>`. The result is a **float**.
  222. .. rst-class:: classref-item-separator
  223. ----
  224. .. _class_float_operator_pow_float:
  225. .. rst-class:: classref-operator
  226. :ref:`float<class_float>` **operator ****\ (\ right\: :ref:`float<class_float>`\ ) :ref:`๐Ÿ”—<class_float_operator_pow_float>`
  227. Raises a **float** to a power of a **float**.
  228. ::
  229. print(39.0625**0.25) # 2.5
  230. .. rst-class:: classref-item-separator
  231. ----
  232. .. _class_float_operator_pow_int:
  233. .. rst-class:: classref-operator
  234. :ref:`float<class_float>` **operator ****\ (\ right\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_float_operator_pow_int>`
  235. Raises a **float** to a power of an :ref:`int<class_int>`. The result is a **float**.
  236. ::
  237. print(0.9**3) # 0.729
  238. .. rst-class:: classref-item-separator
  239. ----
  240. .. _class_float_operator_sum_float:
  241. .. rst-class:: classref-operator
  242. :ref:`float<class_float>` **operator +**\ (\ right\: :ref:`float<class_float>`\ ) :ref:`๐Ÿ”—<class_float_operator_sum_float>`
  243. Adds two floats.
  244. .. rst-class:: classref-item-separator
  245. ----
  246. .. _class_float_operator_sum_int:
  247. .. rst-class:: classref-operator
  248. :ref:`float<class_float>` **operator +**\ (\ right\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_float_operator_sum_int>`
  249. Adds a **float** and an :ref:`int<class_int>`. The result is a **float**.
  250. .. rst-class:: classref-item-separator
  251. ----
  252. .. _class_float_operator_dif_float:
  253. .. rst-class:: classref-operator
  254. :ref:`float<class_float>` **operator -**\ (\ right\: :ref:`float<class_float>`\ ) :ref:`๐Ÿ”—<class_float_operator_dif_float>`
  255. Subtracts a float from a float.
  256. .. rst-class:: classref-item-separator
  257. ----
  258. .. _class_float_operator_dif_int:
  259. .. rst-class:: classref-operator
  260. :ref:`float<class_float>` **operator -**\ (\ right\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_float_operator_dif_int>`
  261. Subtracts an :ref:`int<class_int>` from a **float**. The result is a **float**.
  262. .. rst-class:: classref-item-separator
  263. ----
  264. .. _class_float_operator_div_float:
  265. .. rst-class:: classref-operator
  266. :ref:`float<class_float>` **operator /**\ (\ right\: :ref:`float<class_float>`\ ) :ref:`๐Ÿ”—<class_float_operator_div_float>`
  267. Divides two floats.
  268. .. rst-class:: classref-item-separator
  269. ----
  270. .. _class_float_operator_div_int:
  271. .. rst-class:: classref-operator
  272. :ref:`float<class_float>` **operator /**\ (\ right\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_float_operator_div_int>`
  273. Divides a **float** by an :ref:`int<class_int>`. The result is a **float**.
  274. .. rst-class:: classref-item-separator
  275. ----
  276. .. _class_float_operator_lt_float:
  277. .. rst-class:: classref-operator
  278. :ref:`bool<class_bool>` **operator <**\ (\ right\: :ref:`float<class_float>`\ ) :ref:`๐Ÿ”—<class_float_operator_lt_float>`
  279. Returns ``true`` if the left float is less than the right one.
  280. \ **Note:** :ref:`@GDScript.NAN<class_@GDScript_constant_NAN>` doesn't behave the same as other numbers. Therefore, the results from this operator may not be accurate if NaNs are included.
  281. .. rst-class:: classref-item-separator
  282. ----
  283. .. _class_float_operator_lt_int:
  284. .. rst-class:: classref-operator
  285. :ref:`bool<class_bool>` **operator <**\ (\ right\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_float_operator_lt_int>`
  286. Returns ``true`` if this **float** is less than the given :ref:`int<class_int>`.
  287. .. rst-class:: classref-item-separator
  288. ----
  289. .. _class_float_operator_lte_float:
  290. .. rst-class:: classref-operator
  291. :ref:`bool<class_bool>` **operator <=**\ (\ right\: :ref:`float<class_float>`\ ) :ref:`๐Ÿ”—<class_float_operator_lte_float>`
  292. Returns ``true`` if the left float is less than or equal to the right one.
  293. \ **Note:** :ref:`@GDScript.NAN<class_@GDScript_constant_NAN>` doesn't behave the same as other numbers. Therefore, the results from this operator may not be accurate if NaNs are included.
  294. .. rst-class:: classref-item-separator
  295. ----
  296. .. _class_float_operator_lte_int:
  297. .. rst-class:: classref-operator
  298. :ref:`bool<class_bool>` **operator <=**\ (\ right\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_float_operator_lte_int>`
  299. Returns ``true`` if this **float** is less than or equal to the given :ref:`int<class_int>`.
  300. .. rst-class:: classref-item-separator
  301. ----
  302. .. _class_float_operator_eq_float:
  303. .. rst-class:: classref-operator
  304. :ref:`bool<class_bool>` **operator ==**\ (\ right\: :ref:`float<class_float>`\ ) :ref:`๐Ÿ”—<class_float_operator_eq_float>`
  305. Returns ``true`` if both floats are exactly equal.
  306. \ **Note:** Due to floating-point precision errors, consider using :ref:`@GlobalScope.is_equal_approx<class_@GlobalScope_method_is_equal_approx>` or :ref:`@GlobalScope.is_zero_approx<class_@GlobalScope_method_is_zero_approx>` instead, which are more reliable.
  307. \ **Note:** :ref:`@GDScript.NAN<class_@GDScript_constant_NAN>` doesn't behave the same as other numbers. Therefore, the results from this operator may not be accurate if NaNs are included.
  308. .. rst-class:: classref-item-separator
  309. ----
  310. .. _class_float_operator_eq_int:
  311. .. rst-class:: classref-operator
  312. :ref:`bool<class_bool>` **operator ==**\ (\ right\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_float_operator_eq_int>`
  313. Returns ``true`` if the **float** and the given :ref:`int<class_int>` are equal.
  314. .. rst-class:: classref-item-separator
  315. ----
  316. .. _class_float_operator_gt_float:
  317. .. rst-class:: classref-operator
  318. :ref:`bool<class_bool>` **operator >**\ (\ right\: :ref:`float<class_float>`\ ) :ref:`๐Ÿ”—<class_float_operator_gt_float>`
  319. Returns ``true`` if the left float is greater than the right one.
  320. \ **Note:** :ref:`@GDScript.NAN<class_@GDScript_constant_NAN>` doesn't behave the same as other numbers. Therefore, the results from this operator may not be accurate if NaNs are included.
  321. .. rst-class:: classref-item-separator
  322. ----
  323. .. _class_float_operator_gt_int:
  324. .. rst-class:: classref-operator
  325. :ref:`bool<class_bool>` **operator >**\ (\ right\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_float_operator_gt_int>`
  326. Returns ``true`` if this **float** is greater than the given :ref:`int<class_int>`.
  327. .. rst-class:: classref-item-separator
  328. ----
  329. .. _class_float_operator_gte_float:
  330. .. rst-class:: classref-operator
  331. :ref:`bool<class_bool>` **operator >=**\ (\ right\: :ref:`float<class_float>`\ ) :ref:`๐Ÿ”—<class_float_operator_gte_float>`
  332. Returns ``true`` if the left float is greater than or equal to the right one.
  333. \ **Note:** :ref:`@GDScript.NAN<class_@GDScript_constant_NAN>` doesn't behave the same as other numbers. Therefore, the results from this operator may not be accurate if NaNs are included.
  334. .. rst-class:: classref-item-separator
  335. ----
  336. .. _class_float_operator_gte_int:
  337. .. rst-class:: classref-operator
  338. :ref:`bool<class_bool>` **operator >=**\ (\ right\: :ref:`int<class_int>`\ ) :ref:`๐Ÿ”—<class_float_operator_gte_int>`
  339. Returns ``true`` if this **float** is greater than or equal to the given :ref:`int<class_int>`.
  340. .. rst-class:: classref-item-separator
  341. ----
  342. .. _class_float_operator_unplus:
  343. .. rst-class:: classref-operator
  344. :ref:`float<class_float>` **operator unary+**\ (\ ) :ref:`๐Ÿ”—<class_float_operator_unplus>`
  345. Returns the same value as if the ``+`` was not there. Unary ``+`` does nothing, but sometimes it can make your code more readable.
  346. .. rst-class:: classref-item-separator
  347. ----
  348. .. _class_float_operator_unminus:
  349. .. rst-class:: classref-operator
  350. :ref:`float<class_float>` **operator unary-**\ (\ ) :ref:`๐Ÿ”—<class_float_operator_unminus>`
  351. Returns the negative value of the **float**. If positive, turns the number negative. If negative, turns the number positive. With floats, the number zero can be either positive or negative.
  352. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  353. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  354. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  355. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  356. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  357. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  358. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  359. .. |void| replace:: :abbr:`void (No return value.)`