class_int.rst 2.1 KB

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