Mathematica 9 is now available
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 2007

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

Search the Archive

Re: Number of Differing Digits & Another Problem (want to

  • To: mathgroup at
  • Subject: [mg76340] Re: [mg76310] Number of Differing Digits & Another Problem (want to
  • From: Bob Hanlon <hanlonr at>
  • Date: Sun, 20 May 2007 02:23:41 -0400 (EDT)
  • Reply-to: hanlonr at

Since you intend to count the bit differences your function needs to be modified to



I would use





Bob Hanlon

---- VenDiddy at wrote: 
> I just purchased a copy of Mathematica and I've been learning it for
> about a week now. You can expect that I will be posting a lot of
> questions. One thing I've noticed is that there are so many different
> ways to do the same thing!
> Here is a function I came up with that calculates how many binary
> digits two numbers differ in:
> BitDifferences[a_, b_, n_] :=
>  Count[Equal @@@
>    Thread[{IntegerDigits[a, 2, n], IntegerDigits[b, 2, n]}], True]
> For example 5 = 101 differs from 6 = 111 by one digit (the middle
> digit).
> I want to see how you would do it so I can broaden my Mathematica
> perspective.
> Thanks.

  • Prev by Date: Re: Residue Function
  • Next by Date: Re: [6] LinearAlgebra`MatrixManipulation` LinearEquationsToMatrices
  • Previous by thread: Mathstatica vs. built in symbolic statistics in Version 6
  • Next by thread: Re: Re: Number of Differing Digits & Another Problem (want to