how long does it take
-
Somewhere between 4.5 and 7.2 femtoparsecs.
Software Zen:
delete this;
Fold With Us![^]i mean counting 0 1 2 3 4 5 6 7 .... 2147483647 by the way i m runin it now and i will get the result soon here is what i m doing
DateTime start = DateTime.Now; for (int i = 0; i < int.MaxValue; i++) { Console.WriteLine(i); } DateTime finish = DateTime.Now; Console.WriteLine("counting started at {0} and finished at {1}", start, finish);
-
how long does it take for a computer to count from 0 to the maximum value of int ??
0 milliseconds - the VC++ compiler optimized the useless loop out of the program.
-
i mean counting 0 1 2 3 4 5 6 7 .... 2147483647 by the way i m runin it now and i will get the result soon here is what i m doing
DateTime start = DateTime.Now; for (int i = 0; i < int.MaxValue; i++) { Console.WriteLine(i); } DateTime finish = DateTime.Now; Console.WriteLine("counting started at {0} and finished at {1}", start, finish);
You have to realize you are slowing it down by A LOT by calling
Console.WriteLine(i);
In fact, calling ANYTHING inside that loop will slow it down. remove that line, and run again. also, make sure you run it without optimizations turned on, or the optimizer would just strip the forloop out. -
You have to realize you are slowing it down by A LOT by calling
Console.WriteLine(i);
In fact, calling ANYTHING inside that loop will slow it down. remove that line, and run again. also, make sure you run it without optimizations turned on, or the optimizer would just strip the forloop out.But unless the loop writes something then how do you know the computer is counting...it could be skipping the loop altogether and laughing at you behind your back.
Gary Kirkham Forever Forgiven and Alive in the Spirit The fool has said in his heart, "There is no God" Me blog, You read
-
But unless the loop writes something then how do you know the computer is counting...it could be skipping the loop altogether and laughing at you behind your back.
Gary Kirkham Forever Forgiven and Alive in the Spirit The fool has said in his heart, "There is no God" Me blog, You read
Gary Kirkham wrote:
it could be skipping the loop altogether and laughing at you behind your back.
hehehehe anyway it is runing for more than 1 hour so far what i got is 154500000
-
But unless the loop writes something then how do you know the computer is counting...it could be skipping the loop altogether and laughing at you behind your back.
Gary Kirkham Forever Forgiven and Alive in the Spirit The fool has said in his heart, "There is no God" Me blog, You read
-
how long does it take for a computer to count from 0 to the maximum value of int ??
If a program encounters a loop in a forest, does the computer actually execute it? Marc
-
how long does it take for a computer to count from 0 to the maximum value of int ??
Release, Debug or Plain English?
Deja View - the feeling that you've seen this post before.
-
Gary Kirkham wrote:
it could be skipping the loop altogether and laughing at you behind your back.
hehehehe anyway it is runing for more than 1 hour so far what i got is 154500000
OK - I just ran it and it took 8 seconds.
static void Main(string[] args)
{
Console.WriteLine(DateTime.Now.ToString());
for (int i = 0; i < int.MaxValue; i++)
{
if (i == int.MaxValue - 2)
{
Console.WriteLine("Hi");
}
}
Console.WriteLine(DateTime.Now.ToString());
Console.ReadLine();
}Two things come to mind - why do you want to do this and do you realise you just asked a programming question in the lounge?
Deja View - the feeling that you've seen this post before.
-
Gary Kirkham wrote:
laughing at you behind your back.
Mine does that a lot!
Jon Smith & Wesson: The original point and click interface
I would settle for that...mine openly mocks me.
Gary Kirkham Forever Forgiven and Alive in the Spirit The fool has said in his heart, "There is no God" Me blog, You read
-
how long does it take for a computer to count from 0 to the maximum value of int ??
You can't do that on Vista unless you have SP1 because Vista never finishes calculating how long it's going to take.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001 -
You can't do that on Vista unless you have SP1 because Vista never finishes calculating how long it's going to take.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001On Vista, the answer is "2 seconds remaining." and remains that way till the Sun shrinks to the size of a lump of coal.
Deja View - the feeling that you've seen this post before.
-
Release, Debug or Plain English?
Deja View - the feeling that you've seen this post before.
Pete O'Hanlon wrote:
Plain English
Shhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!
-
But unless the loop writes something then how do you know the computer is counting...it could be skipping the loop altogether and laughing at you behind your back.
Gary Kirkham Forever Forgiven and Alive in the Spirit The fool has said in his heart, "There is no God" Me blog, You read
:laugh: Mine does this all the time - lousy computer!
-
Pete O'Hanlon wrote:
Plain English
Shhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh!
It's like Candyman. If you say Plain English 3 times, up pops Osmo.
Deja View - the feeling that you've seen this post before.
-
On Vista, the answer is "2 seconds remaining." and remains that way till the Sun shrinks to the size of a lump of coal.
Deja View - the feeling that you've seen this post before.
Nonsense - Vista recognises such an operation as a security risk, prompts the user for administrative access and then refuses to run the task regardless :)
-
OK - I just ran it and it took 8 seconds.
static void Main(string[] args)
{
Console.WriteLine(DateTime.Now.ToString());
for (int i = 0; i < int.MaxValue; i++)
{
if (i == int.MaxValue - 2)
{
Console.WriteLine("Hi");
}
}
Console.WriteLine(DateTime.Now.ToString());
Console.ReadLine();
}Two things come to mind - why do you want to do this and do you realise you just asked a programming question in the lounge?
Deja View - the feeling that you've seen this post before.
i m doing it just fo fun :d
-
Nonsense - Vista recognises such an operation as a security risk, prompts the user for administrative access and then refuses to run the task regardless :)
doing it under XP Pro SP2
-
It's like Candyman. If you say Plain English 3 times, up pops Osmo.
Deja View - the feeling that you've seen this post before.
Hmmm. I always thought of him as more as a noxious cloud of bum gas: invisible, lingering and stinking up the joint a treat. :)
-
how long does it take for a computer to count from 0 to the maximum value of int ??
What computer? What language? What compiler? What version of compiler... I guess you’re not interested in result of 16-bit DOS program compiled by compiler with
sizeof(int) = 4
that runs in 32-bit protected mode extender inside virtual 16-bit DOS box on 32-bit Windows 98 running on virtual machine run by 32-bit VirtualPC on 64-bit Vista through WoW64? Or maybe you are? :~Mostly, when you see programmers, they aren't doing anything. One of the attractive things about programmers is that you cannot tell whether or not they are working simply by looking at them. Very often they're sitting there seemingly drinking coffee and gossiping, or just staring into space. What the programmer is trying to do is get a handle on all the individual and unrelated ideas that are scampering around in his head. (Charles M Strauss)