Campbell Ritchie

Marshal
+ Follow
since Oct 13, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
377
In last 30 days
2
Total given
1132
Likes
Total received
8632
Received in last 30 days
18
Total given
702
Given in last 30 days
1
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Campbell Ritchie

Paul Anilprem wrote:. . .

Campbell Ritchie wrote:. . . What is wrong with 65%? . . .


Nah, 65% is below passing. No good  

It might have been a better score if I had hit the right keys
We don't use a file_path in ordinary Java® compiling. It is easiest to navigate to the folder where the XXX.java files are, but it is possible to change the CLASSPATH to gain access to those files.
What is wrong with one file execution? It is easier to use for very small applications, which is what a beginner will want.
19 hours ago
Congratulations What is wrong with 65%? That sounds a good score.
Welcome to the Ranch
We don't simply hand out complete solutions. Please show us what you have acheived so far, even if incomplete.
1 day ago
Please avoid abbreviations like, “w.r.t.,” which may confuse non‑native‑English speakers, and certainly confuses Google Translate.

Moussa Kheyar wrote:Thanks

That's a pleasure

. . . 1111 1111 realy is like below:
(-)111 1111 . . . .

I don't understand that, but it looks incorrect. You have used the leftmost bit as a sign bit, but it has a value.
In eight bits, 1111_1111 is (−128)+64+32+16+8+4+2+1. That gives you −1.
2 days ago

Tim Moores wrote:. . .  https://en.wikipedia.org/wiki/Two%27s_complement

Wikipedia has fallen down there; it calls the leftmost bit the sign bit, which it isn't, even though it always determines the sign of the number, and it incorrectly says that two's complement is determined by inverting the bits and adding 1.
Two's complement numbers are determined by the following procedure:-
  • 1: Determine the base and number of digits. In binary that means base 2 and the number of digits is the same as the numbers of bits. You need to specify that information. It is possible to have complements in other bases than 2.
  • 2: Exactly half the range of the numbers are negative (larger numbers if unsigned) and half (smaller numbers) are non‑negative.
  • 3: Non‑negative numbers look the same as unsigned.
  • 4: For negative numbers, subtract the positive equivalent from one more than the range. In eight‑digit binary, that is 1_0000_0000.
  • Example: the two's complement of 0110_1001 is calculated from
    1_0000_0000
      0110_1001−
      1001_0111

    The fact that zero is represented only once means you have one more negative number than positive number, so the range in 8 bits is -128...127.
    Subtraction from one more, in this case from 2⁸ in binary, is how complement numbers are determined. [Not one's complement.] The flip the bits and add 1 technique always gives the same result as the above subtraction.
    2 days ago

    Moussa Kheyar wrote:. . . the first bit  is used for sign . . .

    That is not quite accurate; Java®'s integer primitive types are not defined in sign and magnitude (=S&M) format, but unsigned (chars) or two's complement (all the others). The leftmost bit is regarded as having a value of −128 if you use 8 bits. As Stephan says, complementary arithmetic makes it very easy to implement both addition and subtraction using the same circuits on the chip, which would be much more difficult in S&M. I think that means two's complement is the de facto default format for all signed integer types.
    It would only be possible to fit −255 into 8 bits if you make all the numbers non‑positive. In unsigned format, the smallest value would be 0.

    I have heard complaints that Java® doesn't support unsigned versions of all integer primitives, but that is a different question, and I think unsigned versions aren't going to happen, ever.
    3 days ago

    Swapnil Mishra wrote:. . . there has to be a way 😢

    Why? Java® was not designed as a low‑level language, but platform‑independent, and the interrupts caused by any key being pressed vary from platform to platform.
    3 days ago

    Mike Simmons wrote:. . . a finally blocks, from a try started immediately after the lock() was called. . . . .

    If the lock() call is inside the try, and it fails, then the count of unlocks will be greater than the count of locks, and you can rely on something nasty going wrong.
    Welcome to the Ranch I hope you have lots of difficult interesting questions, but not on this thread because they won't win the book!

    GB: Please ask your question in a new thread on this forum.

    Bertrand Deweer wrote:. . . amazon reading application. . . .

    In which case, maybe you should complain to Amazon.

    Stephan van Hulst wrote:. . . topographically, we should be in the same time zone as Great Britain.

    Spain is west of Britain and also on CET.

    . . . our winters would be terrible because it would still be dark at 9 o'clock in the morning. . . . .

    Our winters were terrible for that very reason, in 1968‑1971. And it was dark before we finished work at 5. That is why summer time doesn't make sense in the Winter. It might in Iceland, where they only have a few hours of daylight in midwinter anyway.
    And I thought those jokes had quietly died!

    Welcome to the Ranch
    1 week ago