I understand how umask works, at least a basic level, when dealing with the permissions of an executable file or directory. However, I struggle when it comes to how umask applies its rules to text files.
For example, consider the umask 037. On newly created executables or directories I understand that the permissions would arise from a simple subtraction (777-037 = 740). My question though is then how does the apparent subtraction work for determining the permissions on say a text file who's default permissions would be 666.
To be clear how is the subtraction done (666-037 = 637?) obviously having an executable text file makes no sense, and according to some examples I have carried out I know that that the file permissions in such a case should work out to 640.
How is this subtraction done? How do we arrive at 666-037 = 640?