The Crazy Chimp The Crazy Chimp - 10 months ago 69
Objective-C Question

Objective c division of two ints

I'm trying to produce a a float by dividing two

int
s in my program. Here is what I'd expect:

1 / 120 = 0.00833

Here is the code I'm using:

float a = 1 / 120;


However it doesn't give me the result I'd expect. When I print it out I get the following:

inf

Answer Source

Do the following

float a = 1./120.