Right, i was thinking kind of the opposite. If both MSB are 0 there will be no overflow.
Type: Posts; User: Govalant
Right, i was thinking kind of the opposite. If both MSB are 0 there will be no overflow.
There will be an overflow only if both "most significant bits" are 1.
(in your case, that's the 3rd bit from the right)
http://en.wikipedia.org/wiki/Most_significant_bit
EDIT: Sorry, that...
It's not O(n) either, you can't know how the algorithm will behave, for now, all i know is that if n is a power of 2, the complexity will be O(log2(n))
I'm coding something right now to analyze...
The complexity of the 3n + 1 algorithm is not O(3n + 1)
But you still need to check all the numbers to find the maximum.
So it would the complexity of all the numbers (n) multiplied by the complexity of running the 3n+1 algorithm.
And for what i...
Lol all of his threads are titled "new student"
Okey i'll look it up.
So in *nix it isn't possible? :O
Is there a way to make a program run in the background?
Because every program i make pop ups the console.
you used variables with the same name than functions.
don't do that. Always use different names, for the function you could use something like "farTocel", and the vars are far and cel.
15 secons to read thw whole file, which is 114MB
I don't see anything wrong.
But why did you use
*(myArray + (i-1)) = temp;
when you could have used:
This is the only part executing at the time, besides i used some printf's to count the amount of numbers introduced.
Even set() is nothing really.
void set(char T[],int n)
{
T[n/8] &=...
while((c=getc(i)) != EOF)
{
if(isdigit(c))
{
t = (t*10) + c - '0';
} else {
if(t<x*8000000)
{
...
But it's really slow, like 1000 int in 3 seconds.
I'm doing the sort-on-disk problem of programming pearls by the way.
How can i read a file, which consists on about 10M integers separated by \n.
I don't know how to use fscanf and i tried reading char by char and converting to int, but it's too slow.
Thanks.
you need to include stdlib.
maybe in some other compiler it included it automaticaly.
strcat doesn't return the string.
It adds the second to the first
do something like
char* t;
t=malloc(strlen(loadDir)+strlen("personscan.txt")+1);
strcpy(t,loadDir);
First of all, i think your formula is upside down.
Second, your printf should be
printf ("the Farenheit is %f",F);
instead of
ch goes from -128 to 127
aaa from -2 to 1
bbb from -4 to 3
printf("The mean of the three numbers you entered is%i", mean);
You're using %i, it should be %lf. McGyver told you the same earlier.
printf and scanf both use f for float and lf for double.
Exactly =)
multi_tile will be 1 only if norec is different than zero and opt_DM is less than 32.
if those conditions are not true multi_tile will be zero.
Boolean expresions evaluate to 1 or 0, indicating...
don't use unsigned, it just creates trobules.
in some cases
unsigned int a = 5;
int b = 5;
a==b is not true.
When you don't specifiy a condition it evaluates to true if it is different than zero so phase[i] and phase[i]!=0 are the same thing when already compiled.
And that loop will run while the string...