invalid operands of types ‘float’ and ‘float’ to binary ‘operator%’



  • I don't know what a mistake is.

     float a_t_pitch = 30.0;
     ...
     if((a_t_pitch % float(30)) == 0.0)
    

    When assembled, he writes:

    /compass_widget.cpp:76: error: invalid operands of types ‘float’ and ‘float’ to binary ‘operator%’ if(a_t_pitch % float(30)) ♪~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    before, everything was int.

     if((a_t_pitch % 30) == 0)
    

    and everything worked, I can't understand what I'm doing wrong;_;



  • Receipt of balance % Applicable only to counted operars.

    The equivalent of the operation for the floating point chips is performed by the function fmodwhich can be found https://en.cppreference.com/w/cpp/numeric/math/fmod ♪


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2