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
 
Back
Top