Wikipedia:Reference desk/Archives/Computing/2008 November 23
Computing desk | ||
---|---|---|
< November 22 | << Oct | November | Dec >> | November 24 > |
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. |
November 23
editphp large num calculation woes
editAfter viewing e (number), I had an irrational urge to calculate e using the formula . So I got to work. I simply made a php file that contained:
<?php echo pow((1+(1/(<38,613 nines>)), <exact same string of 9's>); ?>
which returns the number 1 . I also tried putting the nines into a variable, for which I used:
<?php $1=<38,613 nines>; echo pow((1+(1/($1))), $1); ?>
Which returns something weird and completely unexpected. 1) Why is it doing that? I'm guessing PHP has built-in truncation, and that's what's doing it, but I'm not sure... and 2) How can I make my unnecessary and irrational fantasy become real (using PHP if at all possible)? flaminglawyercneverforget 00:45, 23 November 2008 (UTC)
- The problem is the variable-name. It can't start with a number, write "$v1" or something instead of "$1". On a related matter, 38,613 nines is an absurdly large number, and I'm not surprised PHP choked on it. Try a much smaller number, like 1,000,000 or something, that should give you a pretty good estimate (I think). If it doesn't, step it up one order of magnitude at a time (or something) 83.250.202.208 (talk) 00:53, 23 November 2008 (UTC)
- I just tested 1,000,000 with google calculator, and it gives e correct to five decimal digits which is, lets face it, pretty much enough. 83.250.202.208 (talk) 00:57, 23 November 2008 (UTC)
- The reason you ended up with "1" is because you've used an extremely large number (Why 38,613 digits particularly?) and run out of precision in the floating point representation used by PHP. See the PHP manual on floating point numbers, and if you really want to play with big numbers, try the BCMath and GMP modules it mentions. - IMSoP (talk) 01:17, 23 November 2008 (UTC)
- Just to clear up the fact that I'm not completely crazy, I got 38613 because I held the 9 button down for a few secs, then copied it, then held down Ctrl+V for a few secs. I didn't have an OCD attack and press the 9 button 38,613 times. flaminglawyercneverforget 01:32, 23 November 2008 (UTC)
- I've run into another problem - even though using a smaller number is correct enough (fixed), the number is still truncated to 12 decimal places. Is there some way to fix that? And (I'm a php/sql n00b), how would I go about installing GMP or BCMath on a free hosting site like I have? flaminglawyercneverforget 01:53, 23 November 2008 (UTC)
- Just to clear up the fact that I'm not completely crazy, I got 38613 because I held the 9 button down for a few secs, then copied it, then held down Ctrl+V for a few secs. I didn't have an OCD attack and press the 9 button 38,613 times. flaminglawyercneverforget 01:32, 23 November 2008 (UTC)
- Personally i wouldn't start abusing a free hosing site like that. They probably have a timeout on your calculations and an alternative is they throw you off for wasting time on their server. You can do the job just as well on your own pc. Dmcq (talk) 11:19, 23 November 2008 (UTC)
- Even for-pay hosting has a timeout on calculations (and a timeout on processor usage). --98.217.8.46 (talk) 15:29, 23 November 2008 (UTC)
- Self-hosting is about a million times easier than remote hosting once you have it set up. If you're only doing it for yourself, why remote host? You have a lot more control when you self-host and you don't have to upload anything ever. --98.217.8.46 (talk) 19:53, 23 November 2008 (UTC)
- I don't like self-hosting because 1) it's not just for me, I'm trying to get my name on this list, and 2) I have a tiny hard drive, and 3) I don't want my processor to be maxxed out 100% with this one problem, because I actually do other things on my computer. flaminglawyercneverforget 21:25, 23 November 2008 (UTC)
- Hosting has nothing to do with a calculation like that. What you are asking is can you dent such a problem with your hardware or using a free hosting and ihe straightforward answer is no you can't and you shouldn't even be trying to as far as his hosting is concerned. Plus you should learn a lot more about the problem before attacking it even if you had good hardware. Anyway why do you mess up your sig with loads of user names?, sounds to me like you value the people answering questions just as much as your hosting provider. Dmcq (talk) 22:53, 23 November 2008 (UTC)
- I don't like self-hosting because 1) it's not just for me, I'm trying to get my name on this list, and 2) I have a tiny hard drive, and 3) I don't want my processor to be maxxed out 100% with this one problem, because I actually do other things on my computer. flaminglawyercneverforget 21:25, 23 November 2008 (UTC)
- Self-hosting is about a million times easier than remote hosting once you have it set up. If you're only doing it for yourself, why remote host? You have a lot more control when you self-host and you don't have to upload anything ever. --98.217.8.46 (talk) 19:53, 23 November 2008 (UTC)
- I'm not going to go to eight indents. I mess up my sig with loads of usernames because I miss them. They were good editors and the got banned/indef-blocked :( . And for your information, I hold my hosting provider in the highest respects. Hey, without them, I wouldn't have any hosting. flaminglawyercneverforget 00:08, 24 November 2008 (UTC)
The PHP code posted here consumes negligible resources, Dmcq. The OP did express an interest in calculating a large number of digits of e; however, this was after your post about time-wasting.To the OP: that formula is not at all how you would actually produce new digits of e — in fact, thepow()
function is probably using an extant value of e in its calculations! You would need specialized software (not PHP) and much bigger hardware to get a place on any modern list. --Tardis (talk) 18:05, 24 November 2008 (UTC)- If you would read the replies a bit more carefully please you would see that I said that after a poster suggested the use of BCMath or GMP and only commented negatively on the OP after he showed he had realized the problem was too big for his computer and that he wanted to run it on the free hosting. Dmcq (talk) 19:57, 24 November 2008 (UTC)
- It wasn't clear to me that your "that" referred to the numerical packages and not to the original approach; you didn't make your statement a reply to the OP's question about installing the packages. My apologies. --Tardis (talk) 15:40, 25 November 2008 (UTC)
- If you would read the replies a bit more carefully please you would see that I said that after a poster suggested the use of BCMath or GMP and only commented negatively on the OP after he showed he had realized the problem was too big for his computer and that he wanted to run it on the free hosting. Dmcq (talk) 19:57, 24 November 2008 (UTC)
NX/XD/DEP
editHow does the NX bit actually work? For example, on Windows, you can set the page protection of each page to something like PAGE_READWRITE instead of PAGE_EXECUTE_READWRITE. Is that the NX bit, or is there another special bit stored somewhere? Also, what is the point of the NX bit if programs (or exploit code) can just change page protection using something like VirtualProtect
? --wj32 t/c 04:54, 23 November 2008 (UTC)
I don't know much about Windows internals, but the idea behind NX bit is to not allow "exploit code" getting inserted to a safe running program, ie if you can't write code segment or execute data segment, things will be more difficult. --194.197.235.221 (talk) 09:45, 24 November 2008 (UTC)
Comparative tests of 256Kb AAC vs. MP3 vs CD?
editI remember there was a listening test years ago comparing 128Kbit AAC vs. MP3 vs WMA. But it seems that 256Kbit is the new high quality standard (both offered by iTunes Plus and Amazon Music). At such a high bit bit rate, is there any discernable different between AAC and MP3 compared to original uncompressed CD audio? —Preceding unsigned comment added by 71.158.214.249 (talk) 05:36, 23 November 2008 (UTC)
In fact, the iTunes music store DOESN'T use conversions from CD format, but instead from higher-fidelity masters. For this reason, 256KBit AAC is actually much better than a CD in terms of fidelity compared with the master. —Preceding unsigned comment added by 86.217.99.209 (talk) 11:26, 23 November 2008 (UTC)
- Well, I'm not asking about listening tests of iTunes Plus, but rather 256Kbit AACs that are from home-ripped CDs. --71.158.214.249 (talk) 13:27, 24 November 2008 (UTC)
- CD audio has a sampling rate of 44.1 kHz (44,100 samples per second) and 16-bit resolution for each channel (stereo). So that's 706kbits/second...quite a bit more than the 256kbit/second you're talking about. However, the compression scheme used is pretty clever and the data it's throwing away is attuned to the kinds of things human ears don't care much about - and not much playback equipment can actually resolve all 16 bits per sample. So in theory, you shouldn't be missing much. However, it's not perfection. Audiophiles claim to be able to hear all sorts of things they can't possibly be hearing (such as the difference between gold connectors and the regular kind for a purely digital signal!) - so you'll get bogus answers if you ask any of them. If I were you - I'd do the experiment...listen to each - see if you can tell the difference. But you've got to do the test 'blind' - you need a friend to switch between the two signal sources a dozen or so times while you have your eyes closed and are listening on the best headphones you can find. You tell him/her whether you think the quality got better or worse each time it switches - and get them to record the results without telling you what happened until the test is over. Then you'll know for sure. SteveBaker (talk) 15:50, 24 November 2008 (UTC)
- Times 2 for 1,411kbps Remember we are talking about stereo sound with two channel. As for the quality, I would referm myself to this article [1] with four persons selected in a diverse population, audiophile being unable after carefull examination to make the difference in some cases. And we are talking about "making a difference" not about the "opinion" or the perceived quality of the sample. As such I would say that 256kbps aac is very probably too close to call, music lover should appreciate.
- As for mp3 vs aac, at high bitrate the quality difference between the different codecs are nearly innexistant, aac quality are more in the domain of the low bitrate like 64kbps where it -is- still sounding like music even though artifacts are clearly noticable unlike the "rock in a tumble drier" sound mp3 is offering. It also got the advantage that it is a standard used in some digital television system, sattelite radios, among other things, while mp3 is mostly barred from those "standard based hardware players" even though software wise and portable audio device wise, mp3 is clearly the most used codec out there. - Esurnir (talk) 19:32, 24 November 2008 (UTC)
- Did you know in WW2 there was a 100 bit per second voice comms between USA and England. Even today most people can't figure out how it was done audibly. :)Dacium (talk) 04:27, 27 November 2008 (UTC)
on screen keyboard
editi had changed my PC settings to show the on screen keyboard.now i'm not able to change this setting. what shall i do? —Preceding unsigned comment added by 117.196.160.197 (talk) 07:24, 23 November 2008 (UTC)
- Assuming you have XP - right-click the bar at the bottom. It should come up with a menu with Toolbars, Cascade Windows, etc. Go to Toolbars > Language bar, and turn it off from there. flaminglawyercneverforget 18:47, 23 November 2008 (UTC)
Different 'Drives'
edithi, basically, how do i change my external hard drive back to drive 'E' from 'F' which it went to cus i was using flash drive...thanks, --90.240.198.176 (talk) 15:29, 23 November 2008 (UTC)
- Start the tool "diskmgmt.msc". You can do this by opening a command line prompt, and typing "start diskmgmt.msc", or by selecting "Run..." in the start menu, and type "diskmgmt.msc". A window will open, which shows a graphical representation of your physical hard disks. Each disk is a rectangle, which is subdivided into smaller rectangles if the disk has more than one partition. Right click the representation of the external hard disk. A pop-up menu will appear. One of the choices will be to change the drive letter of the disk. --NorwegianBlue talk 17:44, 23 November 2008 (UTC)
You may not even have to do that. Unplug both devices, then plug the external HD back in. I have a similar situation with my external HD and mp3 player, though the letters involved there are L: and M:. Matt Deres (talk) 19:57, 27 November 2008 (UTC)
Sony Vegas text editing
editI want to make the text on a video appear gradually, with a fade. So far, it just appears all of a sudden. How do I ensure the former happens? 75.169.206.88 (talk) 19:09, 23 November 2008 (UTC)
Running python scripts with Plain Old Webserver
editI'm trying to use Plain Old Webserver to learn to develop simple web pages with dynamic content. Right now I'm trying to set it up to run python scripts. I've followed the instructions at the POW wiki for getting python up and running with POW: (http://davidkellogg.com/wiki/Pow_programming_languages) but am having no luck. The script in the htdocs directory called 'test.py' containing the line 'print "Hello World"' displays as plain text; accessing [...]/test.py in Firefox displays 'print "Hello World"' rather than the output from running the script.
I'm running Windows XP and not Linux, and so my install directory for python is obviously not /usr/bin/python, but I've pointed the app handler at my local copy of python, and it still doesn't run. Accessing 'test.py' doesn't generate an error log file. access.txt reports a successful (200 OK) request/response.
So, my question is: has anyone gotten this to work successfully on windows? Does anyone have any suggestions about how I might get this working? Or, is there another very lightweight webserver that might work better on windows? Thanks! 35.8.221.45 (talk) 22:16, 23 November 2008 (UTC)
- I put the line in startup.sjs in the wrong location. I fixed that, and now it doesn't work for a different reason. Accessing test.py doesn't display anything, and error.log says:
File "<stdin>", line 1 ECHO is on. ^ SyntaxError: invalid syntax
- If anyone has any insight on this, I'd be grateful to hear it. 35.8.221.45 (talk) 22:38, 23 November 2008 (UTC)
Three questions in one
edit- Can you send folders in an email with hotmail or does it have to be only one file per email?
- I only have hotmail because I must have a Windows Live ID in order to use Windows Live OneCare. Can I open an email account on another service (such as G-Mail?)
- I can no longer sync songs on my iPod because I deleted some playlists. I didn't delete songs from my iTunes library, only certain playlists, so what's up with that? --Crackthewhip775 (talk) 22:52, 23 November 2008 (UTC)
- 1.) You can attach multiple files, or compress a folder into a single zip file, but you can't send a folder. 2.) GMail is free, you can get an account. 3.) Do you only have certain playlists being synced? Look in iTunes when you've connected your iPod and click on the iPod, then on the Music tab. -- JSBillings 23:08, 23 November 2008 (UTC)
- Now I get an error message telling me the email can't be sent because the attachment is too large. I only put 17 pictures, how is that too large? --Crackthewhip775 (talk) 23:19, 23 November 2008 (UTC)
- 17 pics could be huge, depending on the resolution, format/compression, and color depth of each. Check out the sizes for yourself and see. StuRat (talk) 00:29, 24 November 2008 (UTC)
- (e/c) The maximum size for attachments in Hotmail is 10MB (or 20MB if you pay for your account) and you can attach up to 50 attachments. Hotmail's help doesn't actually say you can't attach several 9.9MB attachments, but it implies that when it says "These size limits include the message, encoding, and the attachment, if you added one" - suggesting to me that the mail system can't handle more than the limit. If your pictures are less than ~500KB each, you should be OK; but that's pretty small by today's standards. It is worth noting most mail systems set an upper limit on attachment size, though your ISP could have higher limits than a free webmail service like Hotmail. Astronaut (talk) 00:36, 24 November 2008 (UTC)
- You can use one of these services to send large emails. As for question 2, there is nothing stopping you from creating a GMail account. - Akamad (talk) 01:35, 24 November 2008 (UTC)
- Thanks for the suggestions, guys. --Crackthewhip775 (talk) 04:29, 24 November 2008 (UTC)
- On 2, you can tie a Live ID to any email address, even a gmail one. If you have an existing account, you can change the address if you want at [2] -- Consumed Crustacean (talk) 05:07, 24 November 2008 (UTC)
Curly brackets in Java
editWhat is the effect of having multiple sets of curly brackets where you only need one? I was helping a friend to debug a portion of code, and somehow the extra brackets forced him to make all the methods called within the segment static:
public void addWord(String word, int num) { { //this curly bracket here... //never mind the code in the middle for(int n = 0; n < this.size(); n++) { if(this.get(n).getWord().compareTo(word) == 0) if(!this.get(n).getList().contains(num)) {this.get(n).getList().add(num); return;} } IndexEntry entry = new IndexEntry(word); entry.add(num); this.insertInOrder(entry); } //...and this one here caused some strange errors }
Does anybody know the reason for this? Any help would be appreciated. FlamingSilmaril (talk) 23:12, 23 November 2008 (UTC)
- The only purpose that I know of for defining a block that is not immediately controlled by an if, for, while or other similar statement is to define a block scope for limiting the visibility and lifetime of variables defined within that scope. In the example above, the variable entry would be out-of-scope (inaccessible) following the closing curly brace for that block. If additional code were added to the function after that closing curly brace, it could declare an entirely new variable also named entry, possibly of a completely different type.
- Nested blocks can also be used to intentionally hide variables declared in a containing scope. Suppose the function contained code before the blocks also contained a definition of a variable named entry. The nested block is free to define another variable named entry, which temporarily hides the outer entry variable within its scope. Following that nested block, the outer entry variable is again visible.
- All that said, I don't see how the extra block in the specific example above would have any noticeable effect. What "strange errors" are you getting? -- Tcncv (talk) 02:32, 24 November 2008 (UTC)
- Looking back on it a few hours after the fact, I am unable to reproduce the error right now. I don't remember the exact name of the error, but I believe it was a compile error that said something along the lines of method calls within the block (entry.add(), this.insertInOrder(), etc.) needed to be static. It was worded in a way I had never seen before, though. FlamingSilmaril (talk) 02:41, 24 November 2008 (UTC)
- It helps make your code unmaintainable because maintance developers will to stop and try to figure out why there are extra curly braces for no apparent reason. 216.239.234.196 (talk) 19:34, 24 November 2008 (UTC)
- Looking back on it a few hours after the fact, I am unable to reproduce the error right now. I don't remember the exact name of the error, but I believe it was a compile error that said something along the lines of method calls within the block (entry.add(), this.insertInOrder(), etc.) needed to be static. It was worded in a way I had never seen before, though. FlamingSilmaril (talk) 02:41, 24 November 2008 (UTC)