So I've got a basic math equation I'm trying to perform in programming.
NSInteger testValue = (self.waveform.zoomStartSamples/self.waveform.totalSamples)*100;
Self.waveform.zoomStartSamples is @property (nonatomic, assign) unsigned long int zoomStartSamples;
self.waveform.totalSamples is @property (nonatomic, assign, readonly) unsigned long int totalSamples;
Here are the NSLog's I'm running
NSLog(@"Value of testValue is %ld", (long)testValue);
NSLog(@"zoomStartSamples are %lu", self.waveform.zoomStartSamples);
NSLog(@"totalSamples are %lu", self.waveform.totalSamples);
And here is the result I get:
Value of testValue is 0 zoomStartSamples are 1033554 totalSamples are 4447232
I don't think the value of testValue should be coming up 0. Any ideas?
Ultimately I would like to float the value to another variable to use it elsewhere. Thanks.
This is because
zoomStartSamples/totalSamples
results in a int 0, so 0*100 = 0, try to usezoomStartSamples * 100/totalSamples
instead.