Question: I have a function like this:

```
float_as_thousands_str_with_precision(value, precision)

```

If I use it like this:

```
float_as_thousands_str_with_precision(volts, 1)
float_as_thousands_str_with_precision(amps, 2)
float_as_thousands_str_with_precision(watts, 2)

```

Are those 1/2s magic numbers?

Answer: 
No, they aren't.

A magic number in that context would be a number that has an unexplained meaning. In your case, it specifies the precision, which clearly visible.

A magic number would be something like:

```
int calculateFoo(int input)
{
  return 0x3557 * input;
}

```

You should be aware that the phrase "magic number" has multiple meanings. In this case, it specifies a number in source code, that is unexplainable by the surroundings. There are other cases where the phrase is used, for example in a file header, identifying it as a file of a certain type.
A literal numeral IS NOT a magic number when:

* it is used one time, in one place, with very clear purpose based on its context
* it is used with such common frequency and within such a limited context as to be widely accepted as not magic (e.g. the +1 or -1 in loops that people so frequently accept as being not magic).
* some people accept the +1 of a zero offset as not magic. I do not. When I see variable + 1 I still want to know why, and ZERO\_OFFSET cannot be mistaken.

As for the example scenario of:

float\_as\_thousands\_str\_with\_precision(volts, 1)

And the proposed 

float\_as\_thousands\_str\_with\_precision(volts, HIGH\_PRECISION)

The 1 is magic if that function for volts with 1 is going to be used repeatedly for the same purpose. Then sure, it's "magic" but not because the meaning is unclear, but because you simply have multiple occurences.

Paul's answer focused on the "unexplained meaning" part thinking HIGH\_PRECISION = 3 explained the purpose. IMO, HIGH\_PRECISION offers no more explanation or value than something like PRECISION\_THREE or THREE or 3. Of course 3 is higher than 1, but it still doesn't explain WHY higher precision was needed, or why there's a difference in precision. The numerals offer every bit as much intent and clarity as the proposed labels.

Why is there a need for varying precision in the first place? As an engineering guy, I can assume there's three possible reasons: (a) a true engineering justification that the measurement itself is only valid to X precision, so therefore the display shoulld reflect that, or (b) there's only enough display space for X precision, or (c) the viewer won't care about anything higher that X precision even if its available.

Those are complex reasons difficult to capture in a constant label, and are probbaly better served by a comment (to explain why something is beng done).

IF the use of those functions were in one place, and one place only, I would not consider the numerals magic. The intent is clear.

For reference:

A literal numeral IS magic when 

* "Unique values with unexplained meaning or multiple occurrences which
could (preferably) be replaced with named constants." <http://en.wikipedia.org/wiki/Magic_number_%28programming%29> (3rd bullet)