That will do nicely:
1024x1024 = 1,048,576 (like exeterdad said)
It would be faster to devide through 1,048,576, that saves a multiplication (and a tiny but of memory to hold the 1024) every time that code is executed. The other possibility is to devide through 1,000,000. Both are correct and wrong, it's whichever you think is the correct one that you should use
Depending on the programming language you use you might have to typecast Bytes or 1,048,576 (or both) as (double) floats rather than (long) ints to make sure the answer isn't always rounded down to an integer. For instance, if you'd devide 1,048,575 through 1,048,576 in C without typecasting it, the answer would be 0.