I wanted to create a simple program which would generate random numbers between 0 and 1.
double x2, x3, z0, z1;
int i = 0;
double x0 = 0.3453;
double x1 = 0.3894;
for (i = 0; i < 50; i++)
{
x2 = (x0 + x1)%1.0;
x3 = (x1 + x2)%1.0;
[...]
There is something wrong with line “x2 = …” and “x3 = …”
I’m getting an error: “invalid operands of types ‘double’ and ‘double’ to binary ‘operator%’
the
%modulo operator is for integer values only. If you want to take the modulo of floating point values, you have to use fmod() instead