objective c - Having issues getting a percentage of a number in iOS 7.1 applicaion xcode 5.1 -


In my iOS 7.1 application, which I am trying to develop, I have to find the percentage of that specific number While executing the code in a UITextField, I think the wrong percentage of that number is recorded.

I have tried in two different ways, for which I see the percentage answer is required, but it is giving wrong answer.

I have tried two methods given below.

For example, I have to get 250% to 72%. If you do this on a calculator or better, an excellent spreadsheet gives me the correct answer 250 x 1 - 72% = 70. This is the correct answer that I need

method 1 (.m file) is not working

Values ​​are set specific .text parameters:

  UITextField _linuxOracleOnDiskw_oRTC.text = 250 value UITextField _formulaNumber.text = 1 percent value _linuxOracle_Percent.text = 0.72 _linuxOracleOnDiskwithRTC.text = [set to set to NSString stringWithFormat: @ ".% 2f", ([_linuxOracleOnDiskw_oRTC .text doubleValue]) * ([_ formulaNumber.text doubleValue]) - ([_ linuxOracle_Percent.text doubleValue])];  

When I am executed, then I answer or the valley which is RTC.Techct 249.28 with UITFFIld_Links OracleOnDisc. Thus, it should be wrong 70

The second method is tried:

  name linuxOracleOnDiskw_oRTC = [_linuxOracleOnDiskw_oRTC.text floatValue];  

_linuxOracleOnDiskwithRTC.text = [NSString stringWithFormat: @, (linuxOracleOnDiskw_oRTC * 1 - 72 / 100.0f) "% 2f."];

Can anyone tell me if I am doing wrong and I point out in the right direction, I would be great with the calculation of the percentage of a specific number recorded in a UITPlayfield.

Do not leave your bracket when computing with code "70 x 70 to 72%" To get, you have to do this:

250 x (1 - 0.72) = 250 x 0.28 = 70

The formula () will be calculated first, then multiply and After partition (whichever comes first), then there will be according to the addition and subtraction (whichever is earlier). Therefore, properly insert your brackets.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -