typodupeerror

## Comment one complent, two complement (Score 1)434

They don't have the same unsigned arithmetic.

That seems wrong to me. In fact it seem the wrong way around for me.

For signed binary arithmetic there are two option:

One-Complement: Where we have symmetric positive and negative ranges. Including a negative zero. Seldom used.

Two-Comlement: Where we have asymmetric positive and negative ranges. With the negative range having one extra number.

But for unsigned binary arithmetic I only know one way of doing it. 30 years of experience in the field. More then a dozen programming languages learned. Degree in computer science. I am hard pressed to even think of a different way to do unsigned binary arithmetic. Even on a purely abstract and academic level.

But one is never to old to learn something new and I a the curious type: Please enlighten me!

## Comment Re:Unsigned Byte (Score 1)434

Actually those where UTF-8 characters. slashdot.org converts the UTF+8 characters to HTML entities. Does a good job on it. But then put them out literately. Maybe I have another look at the option.

“sane subtraction 3 - 7 = -4.”

That is only sane in the centre of the valid range. But how about: X = MIN_BYTE + 3; y = x - 7;

The problem was just moved elsewhere where it is not so notable. My main critic on Java is that whenever the investors of Java encountered a difficult to implement possible feature; instead of thinking it through; finding the proper solution; the investors of Java shied away and declared it “unnecessary” or “dangerous”.

I don't blame them. AFAIK Sun what breathing down there Necks telling them to finish by X. Probably also the reason why the few difficult features which did make in (like clone ()) tuned out to be a pigs ear.

## Comment Carry Flag (Score 2)434

True. CPUs do roll over.

And thinking of it (and correcting myself): Ada does for unsigned typed as well. Not for signed. There a RANGE_ERROR is raised. Strange but sometimes useful asymmetry.

But that does not invalidate my statement. All CPU I know of (there might be others, more exotic CPUs of course) set a carry and/or overflow flag on signed and unsigned roll-overs as well. One does not exclude the other here.

In 8 bit times those flags where extremely important to do 16 bit operation with only an 8 bit arithmetic logic unit. That is why it is called carry flag. And of course you can branch on the carry flag set or unset.

Not good enough because Java is missing another important OO Feature: operator overloading. If I may expand the title of the Article &ldquo;Love for the JVM and Hate For Java&rdquo;.

Also: Arithmetic contains great potential for optimisation. But for this the compiler need to know what kind of type he is dealing with:

x + 1 + 2 should be optimized to x + 3
MAX_FOO + 4 should be evaluated at compile time
x < y ||&#160;x = y should be optimized to x <= y

You can still have a library in background to be used by the compiler but the type must be part of the language. The SmallTalk approach that would be.

Anyway: For me the solution was to use Scala when ever I can.

## Comment Ada and Scala (Score 1)434

Ada gives a access to CPU unsigned types without &ldquo;implementation defined&rdquo;. Mind you Ada prescribes RANGE_ERROR on for overflows in signed types and modulo operations on unsigned types. Either way it is well defined.

Scala hides the difference between class Integer and primitive int behind a new type Int. The compiler decides automaticly if a class or primitive should be used. The quite old language SmallTalk does so as well. Primitives are only interesting when you JNI work. Worse case scenario: array of unsigned byte or short in to our out of a JNI call.

Also it should have been build into the compiler. A library is not good enough because Java has no operator overloading. Ada has, Scala has. Almost all other OO Languages have. But not Java.

## Comment Scala (Score 1)434

Spot on. And that is the reason I prefer Scala &mdash; which has operator overloading.

## Comment Re:Unsigned (Score 1)434

Why should that be? All CPU I worked with had both signed and unsigned arithmetic.

## Comment Unsigned Byte (Score 1)434

BTW: The OP said unsigned bytes. As in 0 &#8230; 255. Honestly who needs a byte to go from -128 &#8230; 127 &mdash; that is the most useless data type in the known universe.

## Comment Unsigned Byte (Score 1)434

How about you need 0 &#8230; 255? Very common need in computing.

Java bytes go negative => mayor pain in the arse
short could be negative and 256 onwards => if (x<0 && x> 255) destroying all speed advantages. And you need twice as much memory.

## Comment Do it right not fast (Score 1)434

Of course it is cross platform. If you do it right instead of fast. Because when you do it right you raise ArithmeticException on overflows.

## Comment Re:Unsigned (Score 1)434

Not that slow. Most CPUs do that out of the box employing an overflow or carry flag.

## Comment ArithmeticException (Score 1)434

The is one and only one correct behaviour: 32-unsigned 0 minus 32-unsigned 1 = ArithmeticException &mdash; which is perfectly CPU independent. Obviously Gosling did not think far enough.

## Comment No PGP in Outlook (Score 1)379

Did you notice that none of the big corporation E-Mail clients supports PGP out of the box? And at least Apple Mail breaks the PGP plugin on a regular basis.

I always suspected the governments pressurising the corporation not to add PGP.

# Slashdot Top Deals

Old programmers never die, they just hit account block limit.

Working...