[Tutor] Magic numbers
Phil
phillor9 at gmail.com
Thu Aug 5 03:48:02 EDT 2021
On 5/8/21 4:43 pm, dn via Tutor wrote:
> On 05/08/2021 18.31, Phil wrote:
> It would certainly be more efficient to use a constant, in preference to
> re-calculating each time.
Thank you dn, I'll go with a global constant.
> What is the "128" against which you are comparing the calculation?
128 is bit 7, in this example, of an 8 bit number.
> If you can call it by some name, then give it that name, eg
> fitting_in_seven_bits.
I always have difficulty coming up with descriptive names and that's why
I always end up with magic numbers that can make the code difficult to
follow a fortnight later.
--
Regards,
Phil
More information about the Tutor
mailing list