Looking into it a bit more, this is only part of the problem. There's also
the implicit representation of numbers. For example:

  4 < 12.0

Will throw a ClassCastException too, since the 4 is made into an Integer and
12.0 into a double.

But if we convert everything to Doubles all the time, then we get messiness
like:

    1 + 1 = 2.0

Which isn't what we want.

I'm beginning to think that we should just wrap the numbers into Doubles
when we do the compareTo, and leave everything as it was all other times. Is
that more acceptable?

-Mark

----- Original Message -----
From: "Mark A. Belonga" <[EMAIL PROTECTED]>
To: "Frank Sauer" <[EMAIL PROTECTED]>; "jaxen"
<[EMAIL PROTECTED]>
Sent: Friday, October 19, 2001 11:26 AM
Subject: Re: [Jaxen] number()


> java.lang.Number is an abstract class. We need to make an instance of the
> object. We can refer to the Double elsewhere as a Number, but we still
need
> to instantiate it as something concrete (such as Double or Integer).
>
> -Mark
>
> ----- Original Message -----
> From: "Frank Sauer" <[EMAIL PROTECTED]>
> To: "jaxen" <[EMAIL PROTECTED]>
> Sent: Friday, October 19, 2001 11:21 AM
> Subject: RE: [Jaxen] number()
>
>
> > Why not use the java.util.Number class instead?
> > Who cares if it's an Integer or a Double if all
> > we do is comparing?
> >
> > Frank Sauer
> >
> > -----Original Message-----
> > From: Mark A. Belonga [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, October 19, 2001 12:14 PM
> > To: jaxen
> > Subject: [Jaxen] number()
> >
> >
> > All,
> >
> > Currently, number( value ) will convert the value to a Double only if it
> is
> > already a Double or if it is a string with a decimal place. If it has no
> > decimal place, it will convert value to an Integer.
> >
> > This causes problems when you do something like:
> >
> >     number( '4' ) < number( '12.0' )  (same for '>' as well).
> >
> > Which causes a ClassCastException since we're using compareTo (see
Integer
> > javadocs).
> >
> > I suggest that number ALWAYS converts to a Double. Does anyone disagree?
> Is
> > there any reason we would *not* want to convert to Double?
> >
> > -Mark
> >
> >
> >
> >
> > _______________________________________________
> > Jaxen-interest mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/jaxen-interest
> >
> > _______________________________________________
> > Jaxen-interest mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/jaxen-interest
>
>
> _______________________________________________
> Jaxen-interest mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jaxen-interest


_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest

Reply via email to