class_float.rst 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/makerst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the float.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_float:
  6. float
  7. =====
  8. Float built-in type.
  9. Description
  10. -----------
  11. Float built-in type.
  12. Methods
  13. -------
  14. +---------------------------+-------------------------------------------------------------------------------------+
  15. | :ref:`float<class_float>` | :ref:`float<class_float_method_float>` **(** :ref:`bool<class_bool>` from **)** |
  16. +---------------------------+-------------------------------------------------------------------------------------+
  17. | :ref:`float<class_float>` | :ref:`float<class_float_method_float>` **(** :ref:`int<class_int>` from **)** |
  18. +---------------------------+-------------------------------------------------------------------------------------+
  19. | :ref:`float<class_float>` | :ref:`float<class_float_method_float>` **(** :ref:`String<class_String>` from **)** |
  20. +---------------------------+-------------------------------------------------------------------------------------+
  21. Method Descriptions
  22. -------------------
  23. .. _class_float_method_float:
  24. - :ref:`float<class_float>` **float** **(** :ref:`bool<class_bool>` from **)**
  25. 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.
  26. ----
  27. - :ref:`float<class_float>` **float** **(** :ref:`int<class_int>` from **)**
  28. Cast an :ref:`int<class_int>` value to a floating-point value, ``float(1)`` will be equal to 1.0.
  29. ----
  30. - :ref:`float<class_float>` **float** **(** :ref:`String<class_String>` from **)**
  31. Cast a :ref:`String<class_String>` value to a floating-point value. This method accepts float value strings like ``"1.23"`` and exponential notation strings for its parameter so calling ``float("1e3")`` will return 1000.0 and calling ``float("1e-3")`` will return 0.001. Calling this method with an invalid float string will return 0. This method stops parsing at the first invalid character and will return the parsed result so far, so calling ``float("1a3")`` will return 1 while calling ``float("1e3a2")`` will return 1000.0.
  32. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  33. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  34. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`