Negative int to positive ulong?

  • Thread starter Thread starter Curt Krueger
  • Start date Start date
C

Curt Krueger

I'll spare you the details of why we need this, but what I'm needing to do
is convert -9999 to a positive ulong value.

Any code examples or ideas on how to do this, where to look?

thanks,
Curt
 
Curt Krueger said:
I'll spare you the details of why we need this, but what I'm needing to do
is convert -9999 to a positive ulong value.

Any code examples or ideas on how to do this, where to look?

int x = -9999;
ulong y = unchecked((ulong)x);
Console.WriteLine(y);

prints out 18446744073709541617 - is that what you're after?
 
int x = -9999;
ulong y = unchecked((ulong)x);
Console.WriteLine(y);

prints out 18446744073709541617 - is that what you're after?

Yes it is, thank you very much guys!

Curt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top