Explorar el Código

Add integer absolute value function to math

Michael Ragazzon hace 3 años
padre
commit
13321f66fc
Se han modificado 2 ficheros con 9 adiciones y 0 borrados
  1. 4 0
      Include/RmlUi/Core/Math.h
  2. 5 0
      Source/Core/Math.cpp

+ 4 - 0
Include/RmlUi/Core/Math.h

@@ -107,6 +107,10 @@ RMLUICORE_API bool AreEqual(float value_0, float value_1);
 /// @param[in] value The number of get the absolute value of.
 /// @return The absolute value of the number.
 RMLUICORE_API float AbsoluteValue(float value);
+/// Calculates the absolute value of a number.
+/// @param[in] value The number of get the absolute value of.
+/// @return The absolute value of the number.
+RMLUICORE_API int AbsoluteValue(int value);
 
 /// Calculates the cosine of an angle.
 /// @param[in] angle The angle to calculate the cosine of, in radians.

+ 5 - 0
Source/Core/Math.cpp

@@ -59,6 +59,11 @@ RMLUICORE_API float AbsoluteValue(float value)
 	return fabsf(value);
 }
 
+RMLUICORE_API int AbsoluteValue(int value)
+{
+	return abs(value);
+}
+
 // Calculates the cosine of an angle.
 RMLUICORE_API float Cos(float angle)
 {