Maths formula help

Discussion in 'iOS Programming' started by jpitcairn, Jun 23, 2010.

  1. jpitcairn macrumors member

    Joined:
    Aug 11, 2009
    #1
    I have created an app that calculated audio file sizes. The formula for this calculation is size = sample rate * number of channels * (bits per sample /8) * time in seconds.

    So i have implented this formula using

    Code:
    int bSize = [channelNumber.text intValue] * [bitDepth.text intValue] / 8 * 
    	[sampleRate.text intValue] * [trackLength.text intValue];
    This forumla works for the most part but sometimes can give a negative answer. Any ideas why this is happening?
     
  2. jnic macrumors 6502a

    Joined:
    Oct 24, 2008
    Location:
    Cambridge
    #2

Share This Page