This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Modular Arithmetic (Mod) Operation in CCS ?

I want to take any number's mod but CCS not taking mod. 

I am doing like this things ( Value%100) , but this isn't taking mod.

Can anyone explain this ?

Thanks.

  • We will need more information..
    Does the code compile?
    What data type is Value?
    What answer does it give?
    Can you attach the test case?
    etc...
  • CCS is not compiling my code.
    My Value's type is float.
    This is a error code and expression : #31 expression must have integral type

    And this is my work's code particle ;

    void WriteCon(int Type,float Value,float High_Adress, float Low_Adress){


    if(Type==1){

    //---------------------------------------------//
    I2cMsgOut1.MemoryHighAddr = High_Adress;
    I2cMsgOut1.MemoryLowAddr = Low_Adress;
    //---------------------------------------------//

    I2cMsgOut1.MsgBuffer[0] = Value%100;
    Low_Adress++;

    //---------------------------------------------//
    I2cMsgOut1.MemoryHighAddr = High_Adress;
    I2cMsgOut1.MemoryLowAddr = Low_Adress;
    //---------------------------------------------//

    Low_Adress++;
    I2cMsgOut1.MsgBuffer[1] = (Value-(Value%100))/10;

    }
  • The C language allows the modulus operator (%) to be applied only to integer values, not float values.

    Thanks and regards,

    -George