nagaharikola
asked on
how to find the modulus of flaot values
Hi,
I in my code , at some point i need to find the modulus
float result ;
if result ==.89 then how to find the mod(result/1000).
the compiler is giving error for this operation.
I in my code , at some point i need to find the modulus
float result ;
if result ==.89 then how to find the mod(result/1000).
the compiler is giving error for this operation.
You may use fmod(result/1000.0)
ASKER
i cannot use library function.
is there any other way to do this
is there any other way to do this
what functions can you use?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
be aware that (int)(result/1000.0) is always 0 when abs(result) < 1000.
if result == .89 (as stated in the original post) and you want .89 as the remainder you would do
if you want 890 for remainder (thousandth) simply multiply (not divide) the remainder by 1000.
Sara
if result == .89 (as stated in the original post) and you want .89 as the remainder you would do
remainder = result - (int)result;
if you want 890 for remainder (thousandth) simply multiply (not divide) the remainder by 1000.
Sara