Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Union[{0},{0.}] = {0,0.}?

  • To: mathgroup at
  • Subject: [mg12719] Re: [mg12662] Union[{0},{0.}] = {0,0.}?
  • From: "Tomas Gargz" <tgarza at>
  • Date: Wed, 3 Jun 1998 02:21:08 -0400
  • Sender: owner-wri-mathgroup at

Chris Farr wrote:

>Union[{0},{0.}] ÿ0,0.}.
>I would like the above to return only {0}.
>The root of the problem is that Mathematica thinks they are the same:
>SameQ[{0},{0.}] ÿalse
>How can I get around this?  The following doesn't help either.
>Union[{ N[0] },{0.}] ÿ0,0.}
>Any ides out there?

For one thing, 0 and 0. are distinct elements, so Mathematica is giving
ÿhe right answer.

Now. N[0] will not give 0. as you might like it to. It produces a real,
ÿowever, for any nonzero number.  You could get round the problem by
ÿransforming every real 0. to an integer 0 in the list you are
operating ÿpon with Union (or viceversa).

If your list is b, say,



Union[b/.{x_}->If[xð.,ToExpression[StringTake[ToString[0.], 1]]]]

I hope I did understand your problem.

Tomas Garza
Mexico City 

  • Prev by Date: Problem with Expand[Expr, Trig ->True]
  • Next by Date: Re: How to get PostScript file in text mode.Path:!paulh
  • Previous by thread: Re: Union[{0},{0.}] = {0,0.}?
  • Next by thread: Re: Union[{0},{0.}] = {0,0.}?