You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -6874,13 +6876,16 @@ Sets the seed for the random number generator to ``base``. Setting the seed manu
6874
6876
6875
6877
:ref:`Variant<class_Variant>` **sign** **(** :ref:`Variant<class_Variant>` x **)**
6876
6878
6877
-
Returns the same type of :ref:`Variant<class_Variant>` as ``x``, with ``-1`` for negative values, ``1`` for positive values, and ``0`` for zeros. Supported types: :ref:`int<class_int>`, :ref:`float<class_float>`, :ref:`Vector2<class_Vector2>`, :ref:`Vector2i<class_Vector2i>`, :ref:`Vector3<class_Vector3>`, :ref:`Vector3i<class_Vector3i>`, :ref:`Vector4<class_Vector4>`, :ref:`Vector4i<class_Vector4i>`.
6879
+
Returns the same type of :ref:`Variant<class_Variant>` as ``x``, with ``-1`` for negative values, ``1`` for positive values, and ``0`` for zeros. For ``nan`` values it returns 0.
@@ -6896,13 +6901,14 @@ Returns the same type of :ref:`Variant<class_Variant>` as ``x``, with ``-1`` for
6896
6901
6897
6902
:ref:`float<class_float>` **signf** **(** :ref:`float<class_float>` x **)**
6898
6903
6899
-
Returns ``-1.0`` if ``x`` is negative, ``1.0`` if ``x`` is positive, and ``0.0`` if ``x`` is zero.
6904
+
Returns ``-1.0`` if ``x`` is negative, ``1.0`` if ``x`` is positive, and ``0.0`` if ``x`` is zero. For ``nan`` values of ``x`` it returns 0.0.
6900
6905
6901
6906
::
6902
6907
6903
6908
signf(-6.5) # Returns -1.0
6904
6909
signf(0.0) # Returns 0.0
6905
6910
signf(6.5) # Returns 1.0
6911
+
signf(NAN) # Returns 0.0
6906
6912
6907
6913
.. rst-class:: classref-item-separator
6908
6914
@@ -7169,6 +7175,30 @@ Returns the hyperbolic tangent of ``x``.
7169
7175
7170
7176
----
7171
7177
7178
+
.. _class_@GlobalScope_method_type_convert:
7179
+
7180
+
.. rst-class:: classref-method
7181
+
7182
+
:ref:`Variant<class_Variant>` **type_convert** **(** :ref:`Variant<class_Variant>` variant, :ref:`int<class_int>` type **)**
7183
+
7184
+
Converts the given ``variant`` to the given ``type``, using the :ref:`Variant.Type<enum_@GlobalScope_Variant.Type>` values. This method is generous with how it handles types, it can automatically convert between array types, convert numeric :ref:`String<class_String>`\ s to :ref:`int<class_int>`, and converting most things to :ref:`String<class_String>`.
7185
+
7186
+
If the type conversion cannot be done, this method will return the default value for that type, for example converting :ref:`Rect2<class_Rect2>` to :ref:`Vector2<class_Vector2>` will always return ``Vector2.ZERO``. This method will never show error messages as long as ``type`` is a valid Variant type.
7187
+
7188
+
The returned value is a :ref:`Variant<class_Variant>`, but the data inside and the :ref:`Variant.Type<enum_@GlobalScope_Variant.Type>` will be the same as the requested type.
0 commit comments