Files
godot-docs/classes/class_int.rst
2019-01-07 10:14:12 +01:00

50 lines
2.0 KiB
ReStructuredText

.. Generated automatically by doc/tools/makerst.py in Godot's source tree.
.. DO NOT EDIT THIS FILE, but the int.xml source instead.
.. The source is found in doc/classes or modules/<name>/doc_classes.
.. _class_int:
int
===
**Category:** Built-In Types
Brief Description
-----------------
Integer built-in type.
Methods
-------
+-----------------------+-------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`int<class_int_method_int>` **(** :ref:`bool<class_bool>` from **)** |
+-----------------------+-------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`int<class_int_method_int>` **(** :ref:`float<class_float>` from **)** |
+-----------------------+-------------------------------------------------------------------------------+
| :ref:`int<class_int>` | :ref:`int<class_int_method_int>` **(** :ref:`String<class_String>` from **)** |
+-----------------------+-------------------------------------------------------------------------------+
Description
-----------
Integer built-in type.
Method Descriptions
-------------------
.. _class_int_method_int:
- :ref:`int<class_int>` **int** **(** :ref:`bool<class_bool>` from **)**
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.
- :ref:`int<class_int>` **int** **(** :ref:`float<class_float>` from **)**
Cast a float value to an integer value, this method simply removes the number fractions, so for example ``int(2.7)`` will be equals to 2, ``int(.1)`` will be equals to 0 and ``int(-2.7)`` will be equals to -2.
- :ref:`int<class_int>` **int** **(** :ref:`String<class_String>` from **)**
Cast a :ref:`String<class_String>` value to an integer value, this method is an integer parser from a string, so calling this method with an invalid integer string will return 0, a valid string will be something like ``'1.7'``. This method will ignore all non-number characters, so calling ``int('1e3')`` will return 13.