Sign in to follow this  
BloodLust666

% illegal with floats?

Recommended Posts

BloodLust666    104
y can't i use % with floats??? for what i'm doing, there's no other way i could do it... well, there is, but it would take lots more code that i really don't want to do. Ok, basically, i have a float increasing by something like .15, then i have a constant that i want to see how many times goes into that float. long Num = 128 % myFloat; i keep getting an error saying "illegal right hand use of float" or something like that... anything else i can do?

Share this post


Link to post
Share on other sites
Promit    13246
You can use the fmod() function from the cmath header. (math.h if this is C and not C++, and if it's not C or C++, I don't know.)

Share this post


Link to post
Share on other sites
Wyrframe    2426
Because
(1) traditionally, modulo is only defined for the set of integers anyway, and
(2) because no-one has the guts to implement a hardware floating-point modulo. If you thought floating-point divide was terrifying...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this