Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 14 years ago.
Improve this question
if digit is the name for a number on base 10, what would be the name for a number on base 16? Hexgit?
It's a "nibble" (i.e., half a byte).
http://en.wikipedia.org/wiki/Nibble
Digit. Simply a hexadecimal one.
Are you looking for an analogue to bit for binary digit? Hexgit wouldn't be my choice; it doesn't really roll off the tongue. As for the unit of storage, a hex digit represents a nibble's worth (or nybble).
define: digit
One of the elements that collectively form a system of numeration.
The word 'digit' can be used in any number system. The only exceptions are 'bit' which is really just short for 'binary digit' and 'trit' which is short for 'ternary digit'. (You can still call bits and trits 'digits', however.)
Still "digit", as long as you have 16 fingers ;-)
"Hexdigit" and "hex digit" are both in wide use in textbooks.
There isn't really a consensus, I don't think, but see Units of information for some options.
Personally, I'd just say "hex digit".
"Hexgit" would be a bad choice since "hex" formally suggests base six rather than 16.
"Hexdecit" would retain the 6+10 representation, but I would stick with "digit".
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I'm doing a quiz and I wonder if I can correctly determine it. These are options:
See if a == b is true
Check if a - b == 0 is true
Check if ((a-b)*(a-b))/(a*a + b*b) is close to or is zero
Check a*b == a*a is true
None of the above
I tried to compare float and double values in C++ and I didn't succeed with any of the given formulas. I'd say "None of the above" but I don't know how it works in other languages. I read somewhere that in Java could be different but I would choose the last options as generally other answers are incorrect. What do you think?
The floating-point comparison operation is “perfect” in that it returns true if and only if the tested relation is true. There are never any rounding errors. There is incorrect folklore that you cannot compare floating-point numbers or need to use some tolerance to compare them, but this is because earlier operations that prepare the operands to a comparison typically have rounding errors, similar to the way 7/3 rounds to 2 in integer arithmetic.
If your quiz is based on correct principles of floating-point arithmetic, then “See if a == b is true” is correct. Otherwise, the answer is unclear and the quiz is suspect.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
Expression: z=a+b * b-(36/(b * b)/(1+(25/(b * b)))
I have no idea what data directives I should use and in what order I should write the code.
C = A + B for Z80 CPU:
ld a,A
ld b,B
add a,b ; a = C
C = A * B for 68000 CPU:
MOVE.W D0,A
MOVE.W D1,B
MULS.W D1,D0 ; D0 = C
et cetera ... check your target CPU instruction guide to see what arithmetic operations it does implement directly, and what operand types can be used for them, which registers you have available, and their data type...
Looks like you don't have to write universal math expression parser (this gets tricky quite quickly, once at high-school we had on programming competition the task to write exactly that, and at first we were like "what, a single task for 5h time, I will be done in 30min" ... then after 5h nobody's code passed the full test suite, best were around 80% correct).
So if only this particular expression should be calculated, you can "parse" it by hand, simplifying it down into particular steps involving only single operation and one of intermediate sub-results. Then just write that with your instructions, step by step, like you would calculate that by hand (also make sure you conform to the math expression calculation rules, you know which operations have priority over others? Parentheses override anything, then mul/div first, add/sub later, from left to right, but this is base school math stuff, so unless you are 10y.o., you shouldn't ask this).
If your CPU does not have instruction for division or multiplication, simply implement it by subtraction/addition in loop. It's very lame performance wise, but if you have to ask this question, then one can not expect you would even comprehend more advanced algorithm for these.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
In the book 'Clean Code' by Robert C. Martin, he recommends making use of:
Circle makeCircle(Point center, double radius);
over
Circle makeCircle(double x, double y, double radius);
He basically argues that making a class to avoid using multiple method arguments is preferred.
What is your opinions on this? Please explain to me the benefits, or disadvantages of either.
There are a few reasons for this.
First, it helps to group parameters meaningfully. In this trivial example, it's immediately obvious that x and y go together, but it might not be as immediately obvious when dealing with a more obscure example.
Perhaps more importantly, it cuts down on having too many parameters to keep track of meaningfully; once you have a method that takes more than 3 or 4 parameters, it gets more and more cumbersome to keep track of which parameter is which. Binding parameters together in a class or struct helps avoid that.
Consider this example:
int HowManyMinutesToAirport(int AirportIdentifier, string AirportName, int PlainIdentifier, string PlainName, int PlaneSpeed, string PlaneCompassDirection);
vs.
int HowManyMinutesToAirport(Airport airport, Plane plane);
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I'm asking this question here because I believe this is more of a programmatic issue than anything else.
I'm using a TI-84 Plus Sliver Edition calculator that contains logical operators that can test for less-than, greater-than, and equality. I find that when I input the expression:
2^34 == 2^34 - 1
it gives me a surprising 1 for true. It's worth mentioning that my calculator can't precisely output the result of 2^34. Rather, it uses the exponential notation for it and any other powers greater than 33. Is this a potential factor in the boolean output?
Furthermore, the equality test only returns true if the second expression is subtracting by 1 to 9. When the number is >= 10 it then correctly returns false.
Could it be a rounding error? Why is this expression returning true?
Your calculator cant keep track of numbers that large.
Every calculator has a set level of precision (lets say 10 digits). Every answer the calculator gives is rounded so that the answer has that many digits, then it shifts the decimal place as much as it needs to in order to make the number big or small (in your case very large).
Your number is so large that when you subtract 1, that causes a change after the 10th digit. This then gets rounded back to what you started with, and then compared. So naturally, it thinks they are the same number (to the precision it is capable of).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
Is there a story behind the name ''duck typing'', I've heard ''if it looks like a duck, and sounds like a duck, let's call it a duck'' (or something like that), but why a duck? Why not ``if it looks like a _ and sounds like a _, let's call it a _''.
It sounds like a Flying Circus sketch, but I don't remember it. Is there a story behind the name?
Duck typing is a phrase borrowed from the much older "walk like a duck". The latter has been around far longer than the programming idea it describes. See answerbag.com
http://groups.google.com/group/comp.lang.python/msg/e230ca916be58835?hl=en&
Alex is involved... ;)
This is not really a programming question, but my guess: Ducks walk funny and they quack. This is amusing enough to turn it into a figure of speech. :-)
Quoting Wikipedia's article on Duck Typing:
The name of the concept refers to the duck test, attributed to James
Whitcomb Riley, which may be phrased as follows: "When I see a
bird that walks like a duck and swims like a duck and quacks like a
duck, I call that bird a duck."
...and from the same page...
Alex Martelli made an early (2000) use of the term in a message
to the comp.lang.python newsgroup. He also highlighted
misunderstanding of the literal duck test, which may indicate that the
term was already in use:
"In other words, don't check whether it IS-a duck: check whether it
QUACKS-like-a duck, WALKS-like-a duck, etc, etc, depending on exactly
what subset of duck-like behaviour you need to play your
language-games with."
No, the analogy is that if a variable looks like an integer (for example), and acts as an integer, it must be an integer (type).
Duck typing means 'no explicit predeclaraction of type'.