How to generate all of the numbers of pi in Objective-C [closed] - objective-c

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to create an iPad application named "Am I in Pi?" to check birthday numbers with Pi numbers and show the numbers. My question is how can I generate all of the million numbers of pi 3.1415.... etc. Is there any library in Objective-C or XML file or function that I can use for my implementation?

Rather than generating pi and searching for a certain sequence of digits, you're best off simply saying yes all the time. There is no evidence for any sequence not being in pi.

Grab the 1 megabyte of text for pi.
Writing a script, all 1, 2, 3, and 4 digit sequences exist within this file. Only the following 5 digit sequences don't exist within the first 1M digits of pi:
!!! 14523 not found
!!! 17125 not found
!!! 22801 not found
!!! 33394 not found
!!! 36173 not found
!!! 39648 not found
!!! 40527 not found
!!! 96710 not found
Rather than scanning the text file each time, index the location of all '#', '##', '###', '####' strings.
If you want all 5 or longer digits to be found in the string, include a larger version of the digits of pi.
Calculating the first N million digits of pi on an ipad is a waste of cpu and battery when the data file isn't that large.

Related

2 4-bit binary multiplication in excel [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
Using excel to demonstrate 4-bit x 4-bit binary multiplication as follows:
Convert the multiplier to binary and process one bit at a time
All other operations can be done in decimal.
I have the above question for homework, but it has been given to me by a poor teacher with poor notes. Can anyone give me an idea of where I can read up on the topic? Are there any books (or preferably a link to a webpage) that I could read up on to help me with it?
This is what I have so far. Obviously it's wrong. The thing I'm having trouble with is the addition of the products. I can't simply use =sum() because it 1+1 should equal '0' with a carry. How do I go about achieving this?
Any advice welcome. Thanking you in advance.
Joe.
The problem here is the addition as you correctly point out - but it's wrong in all the calculated cells and not just the cell you highlighted it's just luck that it's the only place you add 1+1.
So, lets work that through with an example that adds a pair of 4-bit binary numbers together in rows 1 & 2. There's an interim calculation to put in row 3 and we'll put the result in row 4.
The least significant bit is simplest and we can restrict this to base 2 (binary) using the MOD function like this =MOD(D1+D2,2) which adds the bits from D1 and D2 and returns 0 where the binary result is 0 or 10 and 1 where it is 1 or 11.
Next we can consider the overflow (or carry) from the less significant operation into the next one...
We can calculate if a bit has overflowed by calculating the integer result of a division by 2. You can calculate the overflow from column D into D3 with =INT((D1+D2)/2) and we can fill that across.
Finally we integrate the carry with the addition, so in C3 we can use =MOD(C1+C2+D3,2) and again fill that back.
Using this you should be able to see how the binary addition works as Excel formulas and work out why your sheet isn't behaving as you expected. Here's the whole calculation in one...
A B C D
1 1 1 1
1 1 1 1
=INT((A1+A2)/2) =INT((B1+B2)/2) =INT((C1+C2)/2) =INT((D1+D2)/2)
=MOD(A1+A2+B3,2) =MOD(B1+B2+C3,2) =MOD(C1+C2+D3,2) =MOD(D1+D2,2)

Finding VERY precise percentiles based on Z-Scores in C/Objective-C? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am creating a program that needs to find thousands of individual percentiles, most of which are less than .00005. Currently, to do this I use
0.5 * erfc(-zScore * M_SQRT1_2)
However, this seems to be rounding slightly (throughout the rest of my program I am using doubles and long doubles, so it has to be this). I believe this because at the end, when I add up all the percentiles, I get 1.835468. This tells me that it is rounding as it should add up 1, or at least a number very close to 1. In addition, when I log each individual percentile, I get the same number (let's say 0.000036) for a few percentiles, and then it goes down to 0.000035. It should be going down each time as each number is further from the mean than the last.
I need a way to find very precise percentiles based on Z-Scores, which this is not giving me as it is rounding too early, at the 6th decimal place.
When you see it jump from 0.000036 to 0.000035, this is because you need to use NSLog(#"Value is: %0.36f", yourPercentile);. You should find that it is not actually rounding at 6 digits, but that was just how it was logged.
Now, your error is coming from the fact that you are using doubles, which do not store precise values very well. First, you need to know how much precision that you need, and then use a type which can handle that level of precision.
Let's say that you decide that you require 12 digits of precision.
long long is then a good unit to use because it can store 19 digits. When you calculate your original value, you need to multiply the original values by 100,000,000,000 and store them as long long's. Then do the math that you need using the large values. Eventually, when you get your result, just divide by the same value (or 2 digits less less if you want to see it as a whole number) to get your percentage.
I believe it's a matter of formatting the number: if two values(long double) are very close each other but still different, you will see them equal, specify the format with something like "%.12Lf".

Calculate the real time of day while in a moving jet plane [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Using VB.Net coding I would like to calculate what the real time is while I'm traveling in a moving jet plane. I will be using this information to remind myself when the time is close to the following times: 04:00, 13:00, 17:00, 19:00 and 21:00
The flight duration is 9 hours and 50 minutes.
The flight leaves Kennedy Airport at 12:50 and arrives in Istanbul at 05:40.
If you can show me the coding required to find 19:00 and 04:00 that would be very much appreciated and I can figure out the other times based on your coding.
I was thinking that if I can figure out how much faster 1 second is than I think I can figure out when the target times will be.
Example: If 1 second on my watch = 3 seconds while on the plane I can figure out that in 10 minutes of travel, the real time has advanced 1/2 hour.
You cannot get an exact time if you don't have a GPS position or the speed and heading of the airplane. What you can do is approximate.
If flight time is 10 hours and you leave at 12.00 you would arrive at 22.00 if you were in the same timezone. The actual time at the destination would be 04.00 if you would pass 6 time zones.
This would mean that 16 passing hours is only 10 hours in "real" time. So 16/10 = 1.6 hours per real hour. This means that time moves 1.6 times faster then in "reality".
Create a program that has a timer and for every second add 0.6 seconds. Start the timer at takeoff.
Or the other way around. Trigger the timer every 1/1.6 seconds and add a second to your clock. This will of course NOT be the real time at your current position but an approximation.

Data Types Obj-C [duplicate]

This question already has an answer here:
Closed 11 years ago.
Exact Duplicate:
Issue with float and double data types in objective C
[Ironically, to find the duplicate questions you need to know the answer.]
What Every Computer Scientist Should Know About Floating-Point Arithmetic
If it cannot be expressed in base 2, it will not be precise. See also floating point inaccuracy.
0.1 is a 'repeating decimal' in binary (0.0001100110011...) so the representation of 0.1 is inexact. NSLog is likely rounding or truncating the output.

What other numeric systems are there? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
There's binary, decimal, hexadecimal, anything else?
Octal (base-8) is another popular one, but there are infinitely many numeric systems.
For example, in Excel the columns are labeled in hexavigesimal (base-26).
Here is a list of popular positional numeric systems.
Then you also have other numeric systems that aren't positional, such as Chinese and Roman numeral systems, but I'm guessing by your examples that you meant strictly positional numeric systems.
You can use any base you like to represent numbers, though it becomes difficult once you move beyond the alphanumeric characters. On the other hand, if you consider a single byte as a "digit", then most (unsigned) integral numbers are stored in base-256 within a computer.
That being said, the only widely-used number system aside from those listed (that I'm aware of) is Octal, which is base-8.
The Babylonians liked base 60 (sexagesimal)...
http://en.wikipedia.org/wiki/Babylonian_numerals
There are infinitely many...check out the Wikipedia page for Arity (specifically n-ary):
Arity - Wikipedia
There are tons of bases for integers (with pretty much everyone knowing base 10).
Also complex, real, & rational.
Wikipedia Number
A numbering system can be formed for any Number n, where n need only be an element of the Hamiltonians or any subset thereof the digits then correspond to the form
{n^k0, n^k0-1, n^k0 -2, ... n^0}.(radix point){n^-1, n^-2, ...,n^k1}
Where k0 is the High order of magnitude, and k1 is the precision