문제

Simply that, it's just that when I put:

float f;
if(f%1){
//do something
//

It returns an error, is there a way to do modulo on float types or i have to do a conversion? I am using xCode IDE and the Objective-C language

도움이 되었습니까?

해결책

Yes, use fmod:

double f = 2.5;
double g = fmod (f, 2.0); // => g = 0.5

다른 팁

% is for integers. Try using fmod().

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top