[Mono-dev] Oddity in C#
alan.mcgovern at gmail.com
Fri Jun 29 16:12:27 EDT 2007
The MSDN documentation for "Read" might help here...
What you'll need to do is read in the console input as a string and use
Convert.ToInt32() (or whatever) to get the input value.
On 6/28/07, Paul F. Johnson <paul at all-the-johnsons.co.uk> wrote:
> Got a bit of a strange one which I'm not sure about. Below is a bit of
> I'm playing with...
> namespace bitcount
> public bitcount
> private uint BitCounter(uint u)
> uint uCount;
> uCount = u - ((u >> 1) & 033333333333) - ((u >> 2) &
> return (uCount + (uCount >> 3) & 030707070707 % 63;
> public static void Main
> bitcount bc = new bitcount();
> uint number;
> Console.WriteLine("Please enter a number ");
> number = Console.Read();
> number = BitCounter(number);
> Okay, it won't compile (Read is static int for a start), but the oddest
> of the puzzle is that the uint variables cause problems when I try to
> (casting). If I change everything to long, the value returned is incorrect
> you re-write this in C or C++ and enter 85, it returns 2, in C# it returns
> Any clues as to why this behaviour is seen? It makes no difference if I
> mono or VS.NET.
> Get your free @ukpost.com account now
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Mono-devel-list