Jump to content

Wikipedia:Reference desk/Archives/Computing/2015 December 11

From Wikipedia, the free encyclopedia
Computing desk
< December 10 << Nov | December | Jan >> December 12 >
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.


December 11

[edit]

what am i doing wrong? (java newby)

[edit]
public class Main {
public static void main(String[] args) {
long a = 3;
long t = 1;
long h = 4;
char d = ' ';
float e = 11.7f;
boolean f = true;
 String output = + t + a + a + "t" + d + h + "a" + "x" + "x" + "o" + "r" + d + e + d + f;
 System.out.println(output);
    }
}
 7t 4axxor 11.7 true

The part at the beginning is supposed to look like "133t" but instead you see the "7t" the rest turned out the way I intended. Where did the 7 come from? what am I doing wrong? 199.19.248.76 (talk) 02:01, 11 December 2015 (UTC)[reply]

I'm not that good with Java myself but you start your string with a + sign. So, I'm guessing, it's adding the first three values 1+3+3 which is where you get 7. Dismas|(talk) 02:04, 11 December 2015 (UTC)[reply]
Even after fixing the + at the beginning I had the same result. I put the letter Z in front and it came up how I intended except I had to put a letter at the beginning in order for it to work. Thank you Dismas. 199.19.248.76 (talk) 02:14, 11 December 2015 (UTC)[reply]
Replace a with String.valueOf(a) and replace t with String.valueOf(t) and replace h with String.valueOf(h) 175.45.116.66 (talk) 02:29, 11 December 2015 (UTC)[reply]
The + operator is left associative, and it means string concatenation if either operand is a string, and numeric addition otherwise. So 1 + 2 + "x" + 3 + 4 = (((1 + 2) + "x") + 3) + 4 = ((3 + "x") + 3) + 4 = ("3x" + 3) + 4 = "3x3" + 4 = "3x34". -- BenRG (talk) 02:40, 11 December 2015 (UTC)[reply]
Just put ""+ at the beginning of the expression. Ruslik_Zero 11:58, 12 December 2015 (UTC)[reply]
[edit]

On this page: [1] the link to the video-game Hocus pocus links back to the page you just came from... Fact is that this game has no page of his own (wich I regret) but I still think it's pretty useless to have a link there that links back to itself. Oxygene7-13 (talk) 14:32, 11 December 2015 (UTC)[reply]

This question might do better at WP:HELP. I think it's fine as-is. Right now Hocus Pocus (computer game) redirects to 3D Realms, but, in the future, if someone makes a page for the game instead of a redirect, then the current link will work to take you to the new article for the game! Also, while it doesn't serve much purpose in that article at present, the redirect helps me find the scant info we do have on the game by using the search box. So I'd suggest you ignore the link, or start on the game article, but there may be relevant official policies on the matter that I'm unaware of. SemanticMantis (talk) 15:09, 11 December 2015 (UTC)[reply]
OK, thanx! Oxygene7-13 (talk) 15:12, 11 December 2015 (UTC)[reply]
See the guideline Wikipedia:Redirect#Self-redirects. CambridgeBayWeather, Uqaqtuq (talk), Sunasuttuq 16:00, 11 December 2015 (UTC)[reply]

Do internal components need drivers?

[edit]

Do the battery, RAM, internal wifi, and anything the computer interacts with need some sort of driver? Is it all included in the BIOS?--Scicurious (talk) 16:32, 11 December 2015 (UTC)[reply]

It depends. RAM is managed by the MMU and the OS - I've never heard that being called "a driver". Batteries can be operated as dumb devices, so you don't strictly need a driver. But built-in wifi, keyboard, mouse, and disk drives certainly need drivers. The bios may have some simple drivers for basic functionality, but most drivers come with the OS proper. --Stephan Schulz (talk) 18:01, 11 December 2015 (UTC)[reply]
If you are working with recent Intel-style computers, there is no BIOS. In its place is a different layer of code, called Unified Extensible Firmware Interface, (or sometimes, a brand-name vendor-specific variation on that theme).
EFI can and does contain device drivers for certain hardware. For other hardware, the operating system must provide the device driver.
Even if you want to compile your own "EFI"-style software from source - which is rare even among kernel hackers - you often still need to include binary blob code (for example, Intel provides binary to configure some of its internal devices - see the Pre-EFI Initialization Core documentation). These types of "blobs" are platform-specific device software; they can include or supplement operating system driver software. A good place to start reading is Intel's Firmware Resource Center (if you are interested in Intel-based computer technology).
Nimur (talk) 18:49, 11 December 2015 (UTC)[reply]
At least on a modern PC, even the RAM needs setup, although after that's done it works untended except by the MMU, as Stephan says. When the system starts, it could have a variety of different RAM devices in different slots, which require different timing configurations. So the boot code (BIOS or UEFI) has to check for each using the SPI bus, read the device types and capabilities from the SIMMs/DIMMs, read any RAM configuration parameters from the non-volatile storage (which itself may be a device on the SPI bus), and then sets the corresponding values up in the MMU registers. Only then can the RAM be written to or read from. That's a non-trivial chunk of code, and for a long time it was painful to write because that code itself couldn't, of course, use the RAM it was setting up - so that code had to run with its only data storage being the CPU's (rather few) registers. Luckily Intel and AMD added support (only about 15 years or so ago, I think) to allow the CPU's cache to work as ordinary addressable RAM (in "no evict" mode) which gives a decent amount of working memory for the boot code to do its RAM device initialisation task. Info about this is here and here. Embedded devices can, usually, assume the type, characteristics, and location of their memory devices will remain constant after manufacture (often because the DRAM devices are surface mounted onto the main board, and can't be swapped or upgraded afterwards), and so can safely read RAM config parameters from the non-volatile storage and know a-priori that they'll work. -- Finlay McWalterTalk 20:00, 11 December 2015 (UTC)[reply]

Doing arithmetic in Java with numbers received from another object

[edit]

New to Java. Can someone help me with a method that adds two numbers, but receives them as message arguments from another object instead of prompting the user or having them hard coded in? I don't know how to have it wait for that input. Thank you. 94.1.49.144 (talk) 20:18, 11 December 2015 (UTC)[reply]

If I understand you correctly, that's just:
int add (int a, int b){
  return a+b;
}
but perhaps I misunderstood. -- Finlay McWalterTalk 20:21, 11 December 2015 (UTC)[reply]
Thanks - I guess my question should have been, is there something I can use as an "automatic" placeholder for each of my numbers, where it's a default part of Java that this placeholder means an integer will be provided as an argument when anything else calls my method? Or do I have to create placeholders myself? I had got as far as:
      int firstNumber, secondNumber;
      firstNumber = _;
      secondNumber = _;
      return firstNumber + secondNumber;
where the underscores are the bits I don't know how to do. 94.1.49.144 (talk) 20:43, 11 December 2015 (UTC)[reply]
When you write int add (int a, int b) {...}, none of the code inside {...} runs until it's called, and when it's called the caller supplies a and b, so there's nothing to wait for. Java methods are not "always alive". Threads are more like what you seem to imagine methods to be. You could create a Java thread that does nothing but wait for inputs on a queue and do some calculation on them and push the result into another queue. That's how a thread pool works, but you probably shouldn't worry about that at this stage of learning Java. -- BenRG (talk) 21:49, 11 December 2015 (UTC)[reply]