need help calculating in xcode - ios

I will explain my project before I get into my question. On the first view you select either UK shoe size (button) or US shoesize (button). then it brings you to another view which has 2 text boxes.(labeled women or mens) If you select men and type a "9" then in the background it does this equation (21.75 + shoeSize) / 3= ans.
It will then take the answer and do this answer / 12 = Feet. Then one the next screen it will have a label that says "how many feet?" then you enter how many feet. In the background it will do this feet * whateverYouPutInBox = steps. Then display the answer on a new screen. I need to know how to do the background equations! (I'm new to iOS programming) this may seem simple to most people. But please help me. If you need anything explained please reply!

Just reverse your equations:
float answer = (21.75 + [shoeSizeTextfield.text floatValue])/3;
float feet = answer/12;
float steps = feet * [numberOfFeetTextField.text floatValue];
And no need to run them in the background since they take a fraction of a second.
But when you say "display on a new screen" what do you mean? You want to transfer the values to another view controller? If so, check out this answer: Passing Data between View Controllers.

Related

How to look back a certain number of days for an indicator and how to only calculate logic upto the last complete bar (i.e. not the current bar)

I'm relatively new to Pine and was having trouble with a couple of things.
So I've got a indicator that I want to look back for the last 5 full days of activity, however not each stock trades in the premarket/afterhours so I want to be able to look back say 5 days and then calculate the number of bars on the time frame (i.e. for a 5 min or hourly resolution). That way I can calculate the number of bars present on the current ticker for that time frame and adjust my indicator length (instead of just having a constant figure of 80 bars or whatever).
The second thing I want to do is only have the indicator update on the completion of a full bar (for example the hourly resolution). So I want it to only calculate up to x-1 bars. Right now I'm finding that it's updating on each new tick. ( I was able to figure this one out, just changed it from i= 0 to length -1 to i=1 to length).
Any help is greatly appreciated.
Thanks,
A

How can I write an mt4 indicator that draws a rectangle and horizontal lines over first 6 hours of hourly candles

I am a quite new to mql4 coding. I would like to know how I write an indicator that does the following, based on the image below:
Draw a rectangle over the current day hour chart that covers the highest and lowest price points of the first 6 hours (candles)
Draw two horizontal lines along the highest and lowest points found 1.
Please note that 1. and 2. should be based strictly on the hourly period and shouldn't vary with the selected period.
I believe I'm suppose to be using ObjectCreate() with OBJ_RECTANGLE and OBJ_HLINE but the whole concept is quite new to me. I would really appreciate some assistance.

Fitting more systems on the first page of a Lilypond score

I'm working to improve upon an excellent sheet I found of Debussy's Deuxième Arabesque on the freely available Mutopia Project.
In particular, I'm interested in fitting the music on fewer pages but I struggle to have the first page display five systems instead of four with the version I arrived at.
From the reproduction above, I would like the fith system (starting at bar 13) to be at the bottom of the first page. It seems there are a lot of wasted space on the first page and I'm rather confident it will fit perfectly.
I have a hard time playing figuring out how to achieve this. I have displayed the spacing annotations as advised by the documentation but I do not seem to be able to make sense of it.
If I were typesetting this today, I would try changing the staff size, like this:
#(set-global-staff-size 18)
You can add the following to your paper block
\paper {
min-systems-per-page = #5
system-system-spacing.padding = #2 %fit staves closer together
system-system-spacing.stretchability = #15 %how flexible the spacing is
}
This will of course force that all other pages have at least five systems. You can play around with the padding and stretchability values and see what works best. Also, you might want to make the staves smaller than the default 20pt. To do that, you can add the following at the beginning of the file:
#(set-global-staff-size 18)

How to continuously Increment & Decrement with (+1) & (-1) in iOS calculator without the Button "="

First sorry for my poor English.
I am creating a basic iOS calculator for iPhone 6, since I am a beginner for iPhone development.
Everything is working fine, addition, subtraction etc.
Now I want to make this calculator app for black jack card counting.
But my question is:
Q) Is it possible to continuously calculate add +1 to the value without the "=" button? That is I want to continuously add +1 when I press (Low +1) button and subtract -1 when I press (High -1) button?
Please give me some suggestion. And Sorry again for my poor English.
Well, one suggestion would be to provide a up and down button (or increment and decrement or whatever else you might call them) which simply added or subtracted one from the current display value.
Depending on how your code is structured, this could be as simple as something like:
case INCR_BTN:
setDisplay (getDisplay() + 1);
break;
case DECR_BTN:
setDisplay (getDisplay() - 1);
break;
(in C, but similar enough to ObjC that it'll help out).
But keep in mind I don't think many of the casinos are going to let you sit at their Blackjack tables messing about with your iPhone :-) The best card counters are the ones that do it in their head but, even then, if you seem to be winning too much, they'll start cutting the shoe earlier to remove any advantage counting may give you.

10 Band Equaliser using NOVOCAINE

Im trying to build a 10 band Equaliser using NOVOCAINE.
I copied the Equaliser.mm's code in viewWillAppear, and added 9 more Sliders in the xib file, and changed IBAction code too this :
-(void)HPFSliderChanged:(UISlider *)sender {
PEQ[sender.tag - 1].centerFrequency = sender.value;
NSLog(#"%f",sender.value);
}
What I want to know is if I am doing this the right way or not ? and the what will be range of the Sliders ? Like in HPF example, the slider range is 2k to 8k. Need some guidance here.
Thanks.
EDIT: after your comment, I think it is clearer what you are asking.
Take the code to instantiate a NVPeakingEQFilter:
NVPeakingEQFilter* PEQ = [[NVPeakingEQFilter alloc] initWithSamplingRate:self.samplingRate];
PEQ.Q = QFactor;
PEQ.G = gain;
PEQ.centerFrequency = centerFrequencies;
you need define 3 parameters: Q, G, and centerFrequency. Both Q and centerFrequency are usually fixed (QFactor in my case is a constant equal to 2.0).
So, you have 10 sliders: each one corresponds to a fixed centerFrequency. I suggested iTunes values: 32Hz, 64Hz, 125Hz, 250Hz, 500Hz, 1KHz, 2KHz, 4KHz, 8KHz, 16KHz. You do not want to change those values when the slider value changes.
What you want to change when the slider value changes is the gain (G). At init time, G can be set to 0.0. This means "no amplification/attenuation".
When the slider moves, you change G, so actually you would do:
PEQ[sender.tag - 1].G = sender.value * kNominalGainRange;
where kNominalGainRange is 12.0, so if sender.value goes from -1.0 to +1.0, G goes from -12 to +12.
Hope this helps.
What I want to know is if I am doing this the right way or not ?
you do not show much code, but HPFSliderChanged seems correct. If you have any specific issue you should describe it and post more code.
and the what will be range of the Sliders ?
Actually, there is no rigid rule when it come to equalisers. iTunes goes from -12db to +12db, but you could use different ranges (with the only caveat being distortion).
Like in HPF example, the slider range is 2k to 8k. Need some guidance here.
again, you can take iTunes equaliser as an example (32Hz, 64Hz, 125Hz, 250Hz, 500Hz, 1KHz, 2KHz, 4KHz, 8KHz, 16KHz), or you can google for images of real equalisers and see which bands they use.

Resources