classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Classpath] RE: Informative throws


From: Eric Blake
Subject: RE: [Classpath] RE: Informative throws
Date: Fri, 27 Jul 2001 17:15:59 +0100

No, I stand by my code.  If the final loop ends with a negative result, it
is necessarily MIN_VALUE, since otherwise there was overflow.
 But -MIN_VALUE == MIN_VALUE, so no harm is done!  Compile it and see...

--
Eric Blake, Elixent, Castlemead, Lwr Castle St., Bristol BS1 3AG, UK
address@hidden   tel:+44(0)117 917 5611


> -----Original Message-----
> From: C. Scott Ananian [mailto:address@hidden
> Sent: 27 July 2001 16:59
> To: Eric Blake
> Cc: address@hidden; classpath
> Subject: Re: [Classpath] RE: Informative throws
>
>
> On Fri, 27 Jul 2001, Eric Blake wrote:
>
> >     if (negative)
> >       return -result;
> >     return result;
> >   }
>
> you actually have to do this the other way 'round (maintain the number
> negative as you build it, then negate it if the number was really
> positive) because the negative range of the integer types is larger than
> the positive range.  Try parsing Integer.MIN_VALUE, for example: your code
> will break.
>  --s




reply via email to

[Prev in Thread] Current Thread [Next in Thread]