Jump to content

Wikipedia:Reference desk/Archives/Computing/2006 September 28

From Wikipedia, the free encyclopedia
< September 27 Computing desk archive September 29 >
Humanities Science Mathematics Computing/IT Language Miscellaneous 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 at one of the pages linked to above.
< August September October >


computer organization

[edit]

please answer the question with explanation

1>A DECIMAL NUMBER HAS 25 DIGITS.THE NUMBER OF BITS NEEDED FOR ITS EQUIVALENT BINARY REPRESENTATION ?

Here's a way you can approximate it:
so that means 10 bits gives you 3 digits (the first digit doesn't count, because it can only be a 0 or 1).
so that means 20 bits gives you 6 digits (the first digit doesn't count, because it can only be a 0 or 1).
so that means 30 bits gives you 9 digits (the first digit doesn't count, because it can only be a 0 or 1).
Continue like this until you get the answer (you may want to add a few more bits to specify the location of the decimal point). StuRat 19:17, 28 September 2006 (UTC)[reply]

The precise answer for an unsigned 25-digit decimal integer N is : log2(N). However, what you probably meant is "what is the integer number of bits needed to represent the largest 25-bit decimal integer?" for this, the answer is rounded_up(log2(1025)), which is rounded_up(25*log2(10)) Arch dude 01:00, 15 October 2006 (UTC)[reply]

2>THE NUMBER OF INSTRUCTIONS NEEDED TO ADD n NUMBERS AND STORE THE RESULT IN MEMORY USING ONLY ONE ADDRESS INSTRUCTIONS

3>Let A be set having 'n' elements.the number of binary operation that can be defined on A ?

4>A certain machine uses expandind opcode.it has 16 bit instructions and 6bit addresses.it supports one address and two address instructions only.if there are'n' two address instructions,the maximum number of one address instruction is---?

5>A COMPUTER USES A FLOATING-POINT REPRESENTATION COMPRISING A SINGNED MAGNITUDE FRACTIONAL MANTISSA AND AN EXCESS-16 base-8 exponent.what decimal number is represented bya a floating-point number whose exponent is 10011,mantissa 101000,and sign bit set?

6>suppose the largest n-bit binary number requires 'd'digits in decimal representation.then what is the relations between 'n' and 'd'?

You should probably read the instructions at the top of this page. Specifically, the one that says:
Do your own homework. If you need help with a specific part or concept of your homework, feel free to ask, but please do not post entire homework questions and expect us to give you the answers.
--Maelwys 14:18, 28 September 2006 (UTC)[reply]

first of all this is not my home work,if you can solve this problem then it will be great help,because i am very weak in co,so please

The 'do you own homework' mantra applies even if it happens to be someone else's! The problem is that this is simple CS and is quite clearly intended for the assignee to learn, not for them to pawn off on others. --Jmeden2000 15:25, 28 September 2006 (UTC)[reply]
I thought the "do your own homework" was code for other Wikipedia users to answer homework questions with complete nonsense. --Kainaw (talk) 01:54, 29 September 2006 (UTC)[reply]

Why do you say the first bit doesn't matter? How do you think the computer keeps track of sign? --frothT C 23:31, 28 September 2006 (UTC)[reply]

Not at all, if you're using unsigned numbers. TERdON 22:41, 21 October 2006 (UTC)[reply]

keyboard - windows xp

[edit]

I use windows xp. When I leave the computer idle for 5 minutes, the keyboard stops functioning. The num lock light in the keyboard glows, but if I press any key, it does not function. I surely think something is fault with windows settings. But I dont know what settings I should try and change. Should I go for setup and try, or should I try doing in control panel? where exactly should I try changing settings?

Thank you

I would guess the power management is set to go to sleep, hibernate, etc., after 5 mins, or that the display is set to go to screen saver, and that interferes with the keyboard. StuRat 18:54, 28 September 2006 (UTC)[reply]
If this is the reason, you can fiddle with these settings in Control Panel -> Display. Try turning the screensaver, hibernation, sleep all off, and see if that makes a difference. Good luck! — QuantumEleven 17:08, 29 September 2006 (UTC)[reply]
You might also need to turn off power management at BIOS level. Please check the manual that came with your Motherboard.

How to open Solaris screenshot rs files?

[edit]

Hi:

How do I open the ".rs" files that contain screenshot images taken with Solaris's "snapshot" program? (Snapshot's interface seems to have that OpenWindows/OpenLook feel to it, so I surmise it's an ancient program).

Thanks,

129.97.252.227 17:39, 28 September 2006 (UTC)[reply]

I don't know, but if you are using windows, you might try Irfanview, it's one of the more popular image viewers that supports a wide variety of files. Alternatively, try The Gimp or ImageMagick
My guess is that .rs is "Sun-raster" netpbm probably includes a converter. --GangofOne 07:06, 14 October 2006 (UTC)[reply]

C++ sending input to another program

[edit]

I'm trying to do 3 things:

1) Run an executable from my program. 2) Wait for it to ask for input and feed it input. 3) Check its output (at this point the executable terminates on its own)

How can I do this with C++? Is there any way to stream it input without actually giving the exe window focus and simulating keypresses or something? Also I'm totally at a loss as to how to check its output. Also will any problems arise with it terminating on its own?

The exe is written in assembly if it makes any difference to the I/O.

Thanks --frothT C 21:20, 28 September 2006 (UTC)[reply]

The POSIX way to do this involves the system calls pipe(), dup2(), fork(), and exec*() (see fork-exec). Basically you set up a pipe to communicate with yourself, then copy yourself (fork()), then arrange for that pipe to be treated as standard input and output in one copy (dup2() and close()) and become the other program you want to execute (exec*()). Then the parent process can just sit and act like the other program's keyboard and screen with its copy of the pipe.
Two caveats: not all of these may be available on Windows (as I presume you are, since you mention an EXE), although it may depend on your compilation setup; also, some (but not all) old DOS programs (which an assembly program might very well be) sometimes behave very badly when their standard input is not connected to a terminal (the keyboard): typically they never terminate. (You can sometimes fix this by making sure the program is told explicitly by its input to terminate, as by including "quit\n" in the text you send it.)
The other progam terminating is no problem, except that if your program is going to do anything else (or you're calling many child programs), it should call wait() (or a variant) after the spawned processes die to clean them up. (It's okay to call wait() before they actually die, so long as you're sure they will do so; your program will, well, wait for them to exit.)
Does that help? (If you can use those functions but can't figure out how to do so, just ask.) --Tardis 22:36, 28 September 2006 (UTC)[reply]
Addendum -- unless you want to use the direct functions read() and write() with the pipes, you'll want to make streams for them. In C, you can always use fdopen(), but there's no standard way to do it in C++ (aside of course from using the C library!). There are, however, common extensions to iostream that let you open a file descriptor as a C++ stream object. --Tardis 22:38, 28 September 2006 (UTC)[reply]
To do this in Windows, call the Windows API function CreateProcess(), declared in windows.h, with the STARTF_USESTDHANDLES flag set in the dwFlags member of the STARTUPINFO struct. The hStdInput and hStdOutput members should then be set to the reading and writing ends of two anonymous pipes, created with CreatePipe() (note you'll probably also want to set the wShowWindow member to SW_HIDE to hide the child process' window as per your requirement, as well as setting the STARTF_USESHOWWINDOW flag). As per the documentation, for this to work the bInheritHandles parameter must be TRUE. ReadFile() and WriteFile() can be used to communicate over the pipe. More information is available from MSDN, however you may have trouble following it unless you are somewhat familiar with Windows systems programming.

Password on USB Drive

[edit]

I have a 256MB SanDisk Freedom.

I would like to put a password on it, just so that when I plug it into either Windows or Mac OSX, I need to enter a password to access it.

My optimum budget for this would be $0

Any ideas would be greatly appreciated.

Omnipotence407 22:27, 28 September 2006 (UTC)[reply]

Truecrypt is the first thing I can think of, but it supports only Linux and Windows, not OSX. -- Consumed Crustacean (talk)
Something works on Linux and not OSX? Weird. --Kainaw (talk) 01:51, 29 September 2006 (UTC)[reply]
If it's a U3-compatible device, just put it in, open the U3 menu, and select "set password" --frothT C 23:28, 28 September 2006 (UTC)[reply]