I'm not sure where the misunderstanding is coming from.
Yes, of course if you have a formula that involves dividing by 2 or something you just include the number directly.
But anything that's a magic number, even if only used once, is better to have a named constant defined. The name of the constant becomes the documentation itself.
The other reason is that if someone needs to come in and maintain the code and change a magic number for whatever reason... if it's a defined constant, they know it should only need to be changed in that one place, assuming all magic numbers are defined in a sufficiently wide scope. If it's just a number, they have to search the whole codebose for all instances of that number, and investigate each and every one to see if it needs to be replaced as well or not.
Yes, of course if you have a formula that involves dividing by 2 or something you just include the number directly.
But anything that's a magic number, even if only used once, is better to have a named constant defined. The name of the constant becomes the documentation itself.
The other reason is that if someone needs to come in and maintain the code and change a magic number for whatever reason... if it's a defined constant, they know it should only need to be changed in that one place, assuming all magic numbers are defined in a sufficiently wide scope. If it's just a number, they have to search the whole codebose for all instances of that number, and investigate each and every one to see if it needs to be replaced as well or not.