magic-numbers

Would These Be Considered Magic Numbers?

Hi, I've just completed writing a program for a programming class, and I want to avoid use of magic numbers, so here's my question: In the function below, would my array indexers be considered magic numbers? Code: string CalcGrade(int s1, int s2, int s3, double median) { const int SIZE = 23; const int LETTER_GRADE_BARRIERS[SIZE] = { ...

how to get magic number of a binary file

there is a magic number associated with each binary file , does anyone know how to retrieve this information from the file? ...

AIX/UNIX: module has an invalid magic number

hi, On AIX, I am executing a script. In this script, it tries to load a 64 bit shared object lib ( .so file) . It fails to do so by giving the following error: The module has an invalid magic number. If I type "prtconf" it shows me that the system is 64 bit. Can anyone help? ...

Finding magic numbers using NDepend

Does anyone know how I could find magic numbers in the source code using the CQL queries in NDepend? This is the same problem as this question, but I don't want to use regex if possible. So I want to find all statements like Int32 someValue = 23; Double anotherValue = 1; but not for (int i = 0; i < array.length; i++) ...

Hard-coded 8191 10485 values in JavaScript rounding function

I've seen the following (bizarre) Javascript rounding function in some legacy code. After googling for it I can see that it crops up in a number of places online. However I can't work out why the hard-coded values 8191 and 10485 are present. Does anyone know if there's any sensible reason why these values are included? If not, hopefu...

Flex SDK 3.5 - Check file magic number

Related to: Flex SDK 3.5 - Check file mimetype Is there a way to get a file's magic number in Flex SDK 3.5 in order to get the file type? ...

Is -1 a magic number? An anti-pattern? A code smell? Quotes and guidelines from authorities

Possible Duplicate: Constant abuse? I've seen -1 used in various APIs, most commonly when searching into a "collection" with zero-based indices, usually to indicate the "not found" index. This "works" because -1 is never a legal index to begin with. It seems that any negative number should work, but I think -1 is almost always...

AddOutParameter - non-magic number way of finding length of DBType.Int32

I have a magic number in the following code... Microsoft.Practices.EnterpriseLibrary.Data.Database db = /* code omitted */; db.AddOutParameter(command, "@ParamName", DbType.Int32, 8); Is there a clean way to get the length of DbType.Int32, as required for the last argument to AddOutParameter? ...

guess what 0x564c is?

when i read linux kernel source, i found one line says: #define NCP_SUPER_MAGIC 0x564c /* Guess, what 0x564c is :-) */ (564c)16 = (22092)10 = (53114)8 = (101011001001100)2 Wolfram|Alpha tells us that 22092 = 2^2 * 3 * 7 * 263 = 43 * 2^9 + 76 ok , so do any body have any ideas of this riddle? btw, this code appea...

What are magic numbers?

What is meant by magic numbers from a programming point of view. ...

Is there a way to remove magic numbers from a XML Schema?

I have a WSDL with some types defined. Some elements accept lists of elements and on the service return I also have elements with list of values (or other elements). As a result I have some magic numbers in the XSD (e.g. minOccurs="10", maxOccurs="250" etc). These values 10, 250 etc are repeated throughout the XSD types. Is there a wa...

How do I avoid both global variables and magic numbers?

I know and understand that global variables and magic numbers are things to avoid when programming, particularly as the amount of code in your project grows. I however can't think of a good way to go about avoiding both. Say I have a pre-determined variable representing the screen width, and the value is needed in multiple files. I coul...

Should I use an enum or multiple const for non-sequential constants in c++?

I'm writing porting file-io set of functions from c into a c++ class. "Magic numbers" (unnamed constants) abound. The functions read a file header which has a number of specific entries whose locations are currently denoted by magic numbers. I was taught by a veteran programmer a couple years back that using "magic numbers" is inher...

About the magic number of PE

0x10b : PE32 executable 0×107 : ROM image 0x20b : PE32+ (64 bit) executable What is the ROM image? ...