Sign in to follow this  

Weird simple CSharp math issue.

This topic is 2055 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a weird bug!
The line
[CODE]
Console.WriteLine(2^32);
Console.WriteLine((uint)2^32);
[/CODE]
both show the result is 34...
And that's basically my entire program.

I ran a loop for each possible number for i from 32 down and did 2^i.
34
29
28
31
30
25
24
27
26
21
20
23
22
17
16
19
18
13
12
15
14
9
8
11
10

Thoughts?

Share this post


Link to post
Share on other sites
What are you expecting it to return? Are you thinking that ^ is a power operator (it's not)?

See here for c# operators: [url="http://msdn.microsoft.com/en-us/library/6a71f45d.aspx"]http://msdn.microsof...y/6a71f45d.aspx[/url]

Share this post


Link to post
Share on other sites

This topic is 2055 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this