Jump to content

Talk:Magic number (programming)

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Data type limits

[edit]

Does § Data type limits really belong in this article? I'm not saying it doesn't belong somewhere, but I am not sure that it belongs here. These limits are not really magic numbers, they are fundamental. The article Integer (computer science), to which Integer type redirects, has them, but only in decimal (and in a sense they are "magic" in decimal as seemingly arbitrary, whereas in hex they are plainly not). I am tempted to add the hex into the Integer article and delete this section: there are no redirects to it, but of course other articles might link to it, and I would check thoroughly they are retargeted if consensus were to make that move.

For that matter, the section should probably be renamed "Integer type limits". 94.21.38.126 (talk) 10:17, 29 November 2019 (UTC)[reply]

I had the same remark. The only justification to keep these limits here would be to provide the name to use instead of writing these magic numbers in code, example INT_MAX in C/C++, however that would become a list of names specific to each language. A reference to headers like <limits.h> in the section "Unnamed numerical constants" should be enough for that article. Teuxe (talk) 13:19, 3 August 2023 (UTC)[reply]

Advantages of naming magic constants

[edit]

The second and last item in the list of advantages,

  • It is easier to alter the value of the number, as it is not duplicated. [...]
  • It facilitates parameterization. [...]

strike me as saying essentially the same thing. I would suggest merging the former into the latter. Mjaðveig (talk) 09:30, 25 September 2023 (UTC)[reply]