Why is the return of my modulo function "-nan(ind)" and what does "-nan(ind)" mean?

  c++, math, modulo, numbers

to practice C++ i decided to write a modulo function.
but it returns

-nan(ind)

how can i make it that the return is the rest of the division?

#include <iostream>
#include "Header.h"



double modulo(double number1, double number2)
{
    double intermediate_result_1=5;
    double result;
    int counter = 0;

    while (intermediate_result_1 < number1)
    {
        counter++;
        intermediate_result_1 = number2 * counter;
        double result = number2-intermediate_result_1;
        return result;
    
    }
}

Source: Windows Questions C++

LEAVE A COMMENT