class_int.rst 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  2. .. DO NOT EDIT THIS FILE, but the doc/base/classes.xml source instead.
  3. .. _class_int:
  4. int
  5. ===
  6. **Category:** Built-In Types
  7. Brief Description
  8. -----------------
  9. Integer built-in type.
  10. Member Functions
  11. ----------------
  12. +------------------------+--------------------------------------------------------------------------+
  13. | :ref:`int<class_int>` | :ref:`int<class_int_int>` **(** :ref:`bool<class_bool>` from **)** |
  14. +------------------------+--------------------------------------------------------------------------+
  15. | :ref:`int<class_int>` | :ref:`int<class_int_int>` **(** :ref:`float<class_float>` from **)** |
  16. +------------------------+--------------------------------------------------------------------------+
  17. | :ref:`int<class_int>` | :ref:`int<class_int_int>` **(** :ref:`String<class_string>` from **)** |
  18. +------------------------+--------------------------------------------------------------------------+
  19. Description
  20. -----------
  21. Integer built-in type.
  22. Member Function Description
  23. ---------------------------
  24. .. _class_int_int:
  25. - :ref:`int<class_int>` **int** **(** :ref:`bool<class_bool>` from **)**
  26. 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.
  27. .. _class_int_int:
  28. - :ref:`int<class_int>` **int** **(** :ref:`float<class_float>` from **)**
  29. 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.
  30. .. _class_int_int:
  31. - :ref:`int<class_int>` **int** **(** :ref:`String<class_string>` from **)**
  32. 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.