This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Handle BINOP_INTDIV in valarith.c


>>>>> "Pierre" == Pierre Muller <muller@ics.u-strasbg.fr> writes:

>> So IOW, yes :)

Pierre>  But this means that like C and unlike pascal
Pierre> '35 / 2' returns a integer of value 17, while for pascal
Pierre> it does return a real of value 17.5.

I must have misunderstood your question.  I thought you were asking if
Java has integer division, which it does.  Anyway, it doesn't matter,
since I think we understand each other.

>> There are also special rules about certain integer divisions.
>> Division by zero throws an exception, and MIN_INT/-1 is defined to be
>> MIN_INT.
Pierre> You probably ment MAX_INT here, no? 

Nope.  Maybe the code is clearer; on some platforms we have to
implement integer divide via this function:

jint
_Jv_divI (jint dividend, jint divisor)
{
  if (__builtin_expect (divisor == 0, false))
    {
      java::lang::ArithmeticException *arithexception 
	= new java::lang::ArithmeticException (JvNewStringLatin1 ("/ by zero"));      
      throw arithexception;
    }
  
  if (dividend == (jint) 0x80000000L && divisor == -1)
    return dividend;

  return dividend / divisor;
}

There is a similar function for long.

>> In Java 5 there is also unboxing, but we never updated gdb to know
>> about that.

Pierre> I almost never used Java, so I have no idea what unboxing means...

A primitive type like 'int' has a corresponding object wrapper type,
e.g., Integer.  Unboxing means the compiler will automatically fetch
the value from an object wrapper.  I.e., this is valid:

    public int add5(Integer x) { return x + 5; }


More than you ever wanted to know about Java, I'm sure :)

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]