Skip to content

Commit

Permalink
Fix Windows compiler warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed Jul 15, 2023
1 parent 757ef4d commit c5d8386
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
13 changes: 6 additions & 7 deletions examples/color_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@
#include <iostream>
#include <gz/math/Color.hh>

int main(int argc, char **argv)
int main(int /*argc*/, char **/*argv*/)
{

//! [Create a color]
gz::math::Color a = gz::math::Color(0.3, 0.4, 0.5);
gz::math::Color a = gz::math::Color(0.3f, 0.4f, 0.5f);
//! [Create a color]
// The channel order is R, G, B, A and the default alpha value of a should be 1.0
std::cout << "The alpha value of a should be 1: " << a.A() << std::endl;



//! [Set a new color value]
a.gz::math::Color::Set(0.6, 0.7, 0.8, 1.0);
a.gz::math::Color::Set(0.6f, 0.7f, 0.8f, 1.0f);
//! [Set a new color value]
std::cout << "The RGBA value of a: " << a << std::endl;

Expand All @@ -41,8 +40,8 @@ int main(int argc, char **argv)

//! [Math operator]
std::cout << "Check if a is Blue: " << (a == gz::math::Color::Blue) << std::endl;
std::cout << "The RGB value of a should be (0, 0, 1): " << a[0] << ", "
<< a[1] << ", "
std::cout << "The RGB value of a should be (0, 0, 1): " << a[0] << ", "
<< a[1] << ", "
<< a[2] << std::endl;
//! [Math operator]

Expand Down
4 changes: 2 additions & 2 deletions include/gz/math/Helpers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ namespace gz
T sum = 0;
for (unsigned int i = 0; i < _values.size(); ++i)
sum += _values[i];
return sum / _values.size();
return sum / static_cast<T>(_values.size());
}

/// \brief Get the variance of a vector of values.
Expand All @@ -367,7 +367,7 @@ namespace gz
T sum = 0;
for (unsigned int i = 0; i < _values.size(); ++i)
sum += (_values[i] - avg) * (_values[i] - avg);
return sum / _values.size();
return sum / static_cast<T>(_values.size());
}

/// \brief Get the maximum value of vector of values.
Expand Down
2 changes: 1 addition & 1 deletion include/gz/math/Polynomial3.hh
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ namespace gz
using std::abs; // enable ADL
const T magnitude = abs(this->coeffs[i]);
const bool sign = this->coeffs[i] < T(0);
const int exponent = 3 - i;
const int exponent = 3 - static_cast<int>(i);
if (magnitude >= epsilon)
{
if (streamStarted)
Expand Down

0 comments on commit c5d8386

Please sign in to comment.