Computing desk | ||
---|---|---|
< December 30 | << Nov | December | Jan >> | January 1 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
When I try to "find" a string, the scroll-bar ends up so positioned that the string I'm searching for is on the lowest line in the window. If a human did that, I'd consider it rude at best. Is there a way to make it appear on the middle line? Michael Hardy ( talk) 00:11, 31 December 2011 (UTC)
First result for a search of 'firefox addon find middle': https://addons.mozilla.org/en-US/firefox/addon/find-to-center/ ¦ Reisio ( talk) 01:20, 31 December 2011 (UTC)
I am purchasing a new Dell XPS 15 laptop with the following customized specs:
This should be fast enough to run BF3 right? What kind of fps can I expect? Acceptable ( talk) 01:17, 31 December 2011 (UTC)
Hi,
I've got two huge tables Sales and Events containing something like things clients bought (this is not really what happens but this example matches the real situation). Events looks like:
eventid, clientid, datetime
Sales contains:
eventid, productid, price
So a Sale is one of the events that can happen to a client. To get all sales for client 12345 we're using a query like this:
select * from sales where eventid in (select eventid from event where clientid=12345)
Obviously a JOIN would be a much better solution, but translating our internal query language to SQL is much easier this way, and MS SQL seems to understand that it's actually supposed to JOIN when I look at the Estimated Execution Plan. This query is done in 30 milliseconds.
Now I want to know: at what prices did client 12345 buy product 678. What SQL seems to think is that it's much faster to find all Sales for product 678 and after that do the difficult join to find out which records apply for client 12345. Unfortunately, this a very slow (3 seconds+) strategy as nearly every client bought 678, but a normal client only bought a couple of items. It would be much faster to find the 20 or so sales for client 12345 and then filter for the product.
Is there anyway I can help SQL understand this? I've been looking into "hints", but I can't find a hint like "filter on this first". All possible indexes are there, and all statistics have been updated.
Txs! Joepnl ( talk) 02:38, 31 December 2011 (UTC)
select price from sales where productid = 678 and eventid in (select eventid from event where clientid = 12345)
select price from sales where eventid in (select eventid from event where clientid = 12345) and productid = 678
I got my first flash drive ... and promptly screwed up. The second time I copied some files to it, I yanked it out without selecting eject. All of the files and folders are gone (no permanent loss). My question is, have I damaged the drive, or can I go ahead and transfer the files again? Clarityfiend ( talk) 02:00, 31 December 2011 (UTC)
I bought an Asus laptop last July which came with Win7. A couple of months ago I installed Ubuntu to dual boot. I've discovered that if, while in Windows, I unplug the power supply and use battery power it says there is 98%. However, in Ubuntu when I unplug it I get a warning that there is insufficient power in the battery and the computer will hibernate. If I plug the power back in I can see that the battery has 98% power left before it shuts down. Any suggestions? CambridgeBayWeather ( talk) 08:08, 31 December 2011 (UTC)
Friends- In your reporting re. Ad-ID your refer to the idea that Ad-ID is a descendant of the "International Standardized Commercial Identifier" or something close to that.
Since I (a) created ISCI in 1969,
(b) proposed it to the AAAAs in early 1970, (c) prepared its first publication for the AAAA's announcement of ISCI's "birth" in Spring 1970, (d) supervised its use by the industry from ISCI's debut, 01JL1970, (e) was its sole "operator" through 31JA1974 when I retired after 23 years with Leo Burnett Advertising (VP-Broadcast Business) and (f) continued to single-handedly operate ISCI until the end of 1992 when I sold the majority (96%) of ISCI coding to the AAAA's and the National Association of Advertisers -
perhaps you will allow me to correct your name (above) to "Industry Standard Commercial Identification".
Although I see that the AAAA's and Ad/ID (which was built upon the ISCI system) announced several years ago that ISCI was being retired, they were possibly in breach of contract unless they made it clear that they were only retiring the 96% of the ISCI codes which they owned. I did not see the announcement. I'm now 97 years of age and at that time was caring for both my bride of 69 years and my 100+ year-old-sister. I hope you will correct the name.
FYI: Incidentally, I will shortly provide Wikipedia with the details regarding "Dole Dating" - a copyrighted dating system I created in 1998 and have urged many to adopt with no fear of copyright infringement. It is the briefest possible foolproof method of expressing dates.
Alors,
David W. Dole — Preceding unsigned comment added by 206.72.27.52 ( talk) 09:11, 31 December 2011 (UTC)
I was going to use my computer today and saw that the wireless network was not working. Tried to see what was the problem and saw that my mymax wireless router power led is off. Tried to plug it on and off again without sucess. What can be the problem? 201.78.191.84 ( talk) 12:35, 31 December 2011 (UTC)
NOTE: Sorry about the formatting of the code if someone can fix this please do so.
#include <stdio.h>
#include <math.h>
int isPrime(int x);
int main(void)
{
...
}
int isPrime(int x)
{
int i;
for (i=2; i <= sqrt((double)x); i++)
if (x % i != 0)
return 0;
return 1;
}
So I've written this program to check whether a number is prime but it won't compile and it has someting to do with the sqrt(). I get a message saying "...: undefined reference to 'sqrt'" "collect2: ld returned 1 exit status" -- 178.208.197.58 ( talk) 18:39, 31 December 2011 (UTC)
pow()
, but using it won't help at all in this case, as it also requires the math library, and suffers from the same problem with comparing integers to floating-point numbers as
User:Wrongfilter mentioned. Using i*i <= x
is the best way to go, in my opinion.
JIP |
Talk 08:37, 1 January 2012 (UTC)constant
is a power of two, compilers will typically rewrite expression % constant
as expression & (constant-1)
, but that otherwise many compilers will compute the integer quotient x / i
in the process of computing x % i
. Are any optimizing compilers smart enough to recognize when both x % i
and x / i
are used within a loop and compute the latter only once, thus doing the division for free? If so, would that encourage writing a trial division primality test as follows? int isPrime(int x)
{
int i = 1;
if(x == 2 || x ==3)
return 1;
if (x % 2 == 0)
return 0;
do {
i += 2;
if (x % i == 0)
return 0;
} while (x / i > i);
return 1;
}
x % 2
is defined to return -1
when x
is a negative odd integer. This means that it will usually generate less efficient code than x & 1
, since the compiler has to check for that case. On the other hand, x % 2 == 0
is the same as (x & 1) == 0
./Ox
flag. For x %= 2
it produces more or less the following: x &= 0x80000001;
if (x < 0)
x = ((x - 1) | 0xFFFFFFFE) + 1;
x %= 3
it produces: unsigned long long y = x * 0x55555556ULL;
x -= ((y >> 63) + (y >> 32)) * 3;
x % 2 == 0
to (x & 1) == 0
. However, gcc 3.4.4 and 4.5.3 for Cygwin with -O2
do make that optimization. All three compilers do just one division per iteration in ToE's code, meaning that it is probably the most efficient implementation of trial division. Funny that I never thought of it before. --
BenRG (
talk) 21:21, 2 January 2012 (UTC)Computing desk | ||
---|---|---|
< December 30 | << Nov | December | Jan >> | January 1 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
When I try to "find" a string, the scroll-bar ends up so positioned that the string I'm searching for is on the lowest line in the window. If a human did that, I'd consider it rude at best. Is there a way to make it appear on the middle line? Michael Hardy ( talk) 00:11, 31 December 2011 (UTC)
First result for a search of 'firefox addon find middle': https://addons.mozilla.org/en-US/firefox/addon/find-to-center/ ¦ Reisio ( talk) 01:20, 31 December 2011 (UTC)
I am purchasing a new Dell XPS 15 laptop with the following customized specs:
This should be fast enough to run BF3 right? What kind of fps can I expect? Acceptable ( talk) 01:17, 31 December 2011 (UTC)
Hi,
I've got two huge tables Sales and Events containing something like things clients bought (this is not really what happens but this example matches the real situation). Events looks like:
eventid, clientid, datetime
Sales contains:
eventid, productid, price
So a Sale is one of the events that can happen to a client. To get all sales for client 12345 we're using a query like this:
select * from sales where eventid in (select eventid from event where clientid=12345)
Obviously a JOIN would be a much better solution, but translating our internal query language to SQL is much easier this way, and MS SQL seems to understand that it's actually supposed to JOIN when I look at the Estimated Execution Plan. This query is done in 30 milliseconds.
Now I want to know: at what prices did client 12345 buy product 678. What SQL seems to think is that it's much faster to find all Sales for product 678 and after that do the difficult join to find out which records apply for client 12345. Unfortunately, this a very slow (3 seconds+) strategy as nearly every client bought 678, but a normal client only bought a couple of items. It would be much faster to find the 20 or so sales for client 12345 and then filter for the product.
Is there anyway I can help SQL understand this? I've been looking into "hints", but I can't find a hint like "filter on this first". All possible indexes are there, and all statistics have been updated.
Txs! Joepnl ( talk) 02:38, 31 December 2011 (UTC)
select price from sales where productid = 678 and eventid in (select eventid from event where clientid = 12345)
select price from sales where eventid in (select eventid from event where clientid = 12345) and productid = 678
I got my first flash drive ... and promptly screwed up. The second time I copied some files to it, I yanked it out without selecting eject. All of the files and folders are gone (no permanent loss). My question is, have I damaged the drive, or can I go ahead and transfer the files again? Clarityfiend ( talk) 02:00, 31 December 2011 (UTC)
I bought an Asus laptop last July which came with Win7. A couple of months ago I installed Ubuntu to dual boot. I've discovered that if, while in Windows, I unplug the power supply and use battery power it says there is 98%. However, in Ubuntu when I unplug it I get a warning that there is insufficient power in the battery and the computer will hibernate. If I plug the power back in I can see that the battery has 98% power left before it shuts down. Any suggestions? CambridgeBayWeather ( talk) 08:08, 31 December 2011 (UTC)
Friends- In your reporting re. Ad-ID your refer to the idea that Ad-ID is a descendant of the "International Standardized Commercial Identifier" or something close to that.
Since I (a) created ISCI in 1969,
(b) proposed it to the AAAAs in early 1970, (c) prepared its first publication for the AAAA's announcement of ISCI's "birth" in Spring 1970, (d) supervised its use by the industry from ISCI's debut, 01JL1970, (e) was its sole "operator" through 31JA1974 when I retired after 23 years with Leo Burnett Advertising (VP-Broadcast Business) and (f) continued to single-handedly operate ISCI until the end of 1992 when I sold the majority (96%) of ISCI coding to the AAAA's and the National Association of Advertisers -
perhaps you will allow me to correct your name (above) to "Industry Standard Commercial Identification".
Although I see that the AAAA's and Ad/ID (which was built upon the ISCI system) announced several years ago that ISCI was being retired, they were possibly in breach of contract unless they made it clear that they were only retiring the 96% of the ISCI codes which they owned. I did not see the announcement. I'm now 97 years of age and at that time was caring for both my bride of 69 years and my 100+ year-old-sister. I hope you will correct the name.
FYI: Incidentally, I will shortly provide Wikipedia with the details regarding "Dole Dating" - a copyrighted dating system I created in 1998 and have urged many to adopt with no fear of copyright infringement. It is the briefest possible foolproof method of expressing dates.
Alors,
David W. Dole — Preceding unsigned comment added by 206.72.27.52 ( talk) 09:11, 31 December 2011 (UTC)
I was going to use my computer today and saw that the wireless network was not working. Tried to see what was the problem and saw that my mymax wireless router power led is off. Tried to plug it on and off again without sucess. What can be the problem? 201.78.191.84 ( talk) 12:35, 31 December 2011 (UTC)
NOTE: Sorry about the formatting of the code if someone can fix this please do so.
#include <stdio.h>
#include <math.h>
int isPrime(int x);
int main(void)
{
...
}
int isPrime(int x)
{
int i;
for (i=2; i <= sqrt((double)x); i++)
if (x % i != 0)
return 0;
return 1;
}
So I've written this program to check whether a number is prime but it won't compile and it has someting to do with the sqrt(). I get a message saying "...: undefined reference to 'sqrt'" "collect2: ld returned 1 exit status" -- 178.208.197.58 ( talk) 18:39, 31 December 2011 (UTC)
pow()
, but using it won't help at all in this case, as it also requires the math library, and suffers from the same problem with comparing integers to floating-point numbers as
User:Wrongfilter mentioned. Using i*i <= x
is the best way to go, in my opinion.
JIP |
Talk 08:37, 1 January 2012 (UTC)constant
is a power of two, compilers will typically rewrite expression % constant
as expression & (constant-1)
, but that otherwise many compilers will compute the integer quotient x / i
in the process of computing x % i
. Are any optimizing compilers smart enough to recognize when both x % i
and x / i
are used within a loop and compute the latter only once, thus doing the division for free? If so, would that encourage writing a trial division primality test as follows? int isPrime(int x)
{
int i = 1;
if(x == 2 || x ==3)
return 1;
if (x % 2 == 0)
return 0;
do {
i += 2;
if (x % i == 0)
return 0;
} while (x / i > i);
return 1;
}
x % 2
is defined to return -1
when x
is a negative odd integer. This means that it will usually generate less efficient code than x & 1
, since the compiler has to check for that case. On the other hand, x % 2 == 0
is the same as (x & 1) == 0
./Ox
flag. For x %= 2
it produces more or less the following: x &= 0x80000001;
if (x < 0)
x = ((x - 1) | 0xFFFFFFFE) + 1;
x %= 3
it produces: unsigned long long y = x * 0x55555556ULL;
x -= ((y >> 63) + (y >> 32)) * 3;
x % 2 == 0
to (x & 1) == 0
. However, gcc 3.4.4 and 4.5.3 for Cygwin with -O2
do make that optimization. All three compilers do just one division per iteration in ToE's code, meaning that it is probably the most efficient implementation of trial division. Funny that I never thought of it before. --
BenRG (
talk) 21:21, 2 January 2012 (UTC)