Timeline for Convert number from one radix to another
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 15, 2017 at 11:38 | vote | accept | CommunityBot | ||
Aug 14, 2017 at 21:16 | comment | added | user146374 |
Regarding convertToDecimal() , I still can't quite wrap my brain around what you're saying. All primitive datatypes are binary, but all calculations are, for all intents and purposes it seems, decimal. For instance, the statement System.out.print(1 + 1); prints "2"—not "10" as binary would have it. So when a—say—hexadecimal number "B3" is transformed by the method into the decimal number "179", why is it fallacious to call that a decimal number if it works, acts, and looks like a decimal number even though the computer knows it to be 10110011?
|
|
Aug 14, 2017 at 21:09 | comment | added | user146374 |
Regarding package test , I suppose I'll be able to better understand that later once I've acquired more knowledge about programming in general. Thanks.
|
|
Aug 14, 2017 at 14:04 | comment | added | Ralf Kleberhoff |
Regarding "decimal": your convertToDecimal() method returns an int, which is, as you correctly say, a binary thing, and has nothing to do with a decimal representation - decimal is the duty of toString() methods and so on.
|
|
Aug 14, 2017 at 14:02 | comment | added | Ralf Kleberhoff |
package test places your class into a namespace. So the full-length name of my class is test.Test . Placing code into a package makes it less likely to collide with some library's other class. An established convention is to use a reversed internet domain as prefix for your packages, e.g. com.stackexchange.codereview.test.whatever - if we were the "owners" of stackexchange. Then there can't be any collisions.
|
|
Aug 14, 2017 at 8:04 | comment | added | user146374 | Thank you for the great feedback. I noticed the first line of the code you provided has "package test;". Perhaps this is a silly question, but what is that for? What does it do? Additionally, regarding the convertToDecimal method, I'm still not quite sure I understand. It is my understanding that all primitive datatypes are binary, so why is it fallacious to refer to something that represents decimal numbers as "decimal"? Thanks again. | |
Aug 13, 2017 at 18:09 | history | answered | Ralf Kleberhoff | CC BY-SA 3.0 |