I'm taking a permission number and outputting it as an octal

Code:
 (0777 & perm)
and I want to compare it with the permission number '777' but I don't know how to compare these two. Anyone?