code_junkie

Strange c# overflow error

Nov 13th, 2011
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3. int i = 2;
  4. long a = 1024 * 1024 * 1024 * i;
  5. long b = 12345678901234567;
  6. System.Console.WriteLine("{0}", a);
  7. System.Console.WriteLine("{0}", b);
  8. System.Console.WriteLine("{0}", long.MaxValue);
  9. }
  10.  
  11. -2147483648
  12. 12345678901234567
  13. 9223372036854775807
  14. Press any key to continue . . .
  15.  
  16. long a = 1024L * 1024 * 1024 * i;
Add Comment
Please, Sign In to add comment