Skip to content

Instantly share code, notes, and snippets.

@salmaanahmed
Created January 28, 2019 11:55
Show Gist options
  • Save salmaanahmed/f5d096d2222644f476f62380829d32d5 to your computer and use it in GitHub Desktop.
Save salmaanahmed/f5d096d2222644f476f62380829d32d5 to your computer and use it in GitHub Desktop.
The problem with finding even number in swift
// Swift:
7 % 2 == 1 // true
-7 % 2 == 1 // false. -7 % 2 evaluates to -1
// Ruby and Python
7 % 2 == 1 // true
-7 % 2 == 1 // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment