Search code examples
iphoneiosinfinity

INFINITY problem while dividing is iOS


I am getting infinity problem in an iPhon application. The problem is very strange. I need to calculate the zoom limit using the following formula.

zoomLimit = 1/(mapState.iBufferMult*0.75);

The value of mapState.iBufferMult = 3

The problem is that most of the type the formula gives the correct value 0.44. But sometimes it gives INFINITY.

Can anyone tell me why it is doing like that.


Solution

  • Can anyone tell me why it is doing like that.

    Yes, I can: when mapState.iBufferMult is 0 (zero) then:

    zoomLimit = 1/(mapState.iBufferMult*0.75)
              = 1/(0*0.75)
              = 1/0
              = INFINITY
    

    Solve the mapState.iBufferMult problem and you've solved this one.