2

to-the-point question here. sorry.

I am trying to understand *normalization** in terms of mathematics.

In the toxiclibs library one can normalise a float. Why one would want to normalize a float... In 3D I get that a normal of 3 dimentional plane can give the up. First thought: it is to do with preformance. But then I found this SO question explaining how a game UI may use it. This... I kind of get.

Would it be fair to say one would normalised a float where there is a max and minimum? Two scenarios I can think of:

  1. CSS Color RGBA: RGB is from 0 to 255 but could, theoretically, go higher. Whereas A is from 0.0 to 1.0. Is this normalized as it can be completely transparent or opaque, therefore it is a normal because there is a definative 0 or 1?

  2. When recording music (or looking at a wave form), it can be clipped. Is this because there is a max and a min, so a normalized value above 1 would be clipped? I guess, in this case, normalise would be for convenience.

So, why normalize a float? Is it performance? Readabilty? Something else (visual reference == Kudos)? Does a Spinal Tap Amp going all the way up to 11 have anything to do with this?

1
  • 1
    As Jim pointed out, normalizing a vector (or plane) is not the same as normalizing a float. These are two rather different concepts that happen to have the same name.
    – Mashmagar
    Feb 16, 2011 at 21:24

4 Answers 4

5

A brief explanation of "normalized" floats

In scientific notation, you write any number as x.y * 10^z, where x is a single non-zero digit. For example 212 = 2.12 * 10^2. It's always possible for x to be a single digit, because you can keep dividing by 10. Likewise, it's always possible for x to be non-zero, because you can keep multiplying by 10 except when trying to write the value 0. 0 in scientific notation just ends up as 0.0 * 10^0.

More about scientific notation

Moving on to floats... Floats are basically scientific notation in binary. They are written in the form x.y * 2^z. x is still a single non-zero digit, but in binary that only leaves one option: 1! If you're implementing floating point storage in a computer, you don't want to waste a bit that is always 1, so you only store y and z (and +/-).

But now how do you store 0? It turns out that a special value of z is used to mean "x is actually 0." Then you can store 0.0. But you can also store 0.0010100011000 * 2^(special z) and all sorts of "denormal" values.

I don't understand what toxiclib's normalize function does - I was unable to find the documentation. As far as I was aware, denormal floats have no equivalent normalized representation for the same precision float (a denormal single could be represented as a normal double, but not as a normal single). Perhaps that's what the function is doing. But unless you're dealing with some really low-level stuff or high-precision, you probably don't care.

Eric Lippert has a good explanation of the anatomy of a float.

0
3

I know this is a stale thread, but FWIW (I'm the author of the above mentioned toxiclibs) - I usually prefer to work with normalized values (i.e. both in the 0.0 .. 1.0 or -1.0 ... +1.0 interval) simply because it keeps them more flexible when working in multiple domains. You simply have an associated scale value or mapping coefficient which is applied whenever the value is used. This allows me to keep the actual absolute range definitions outside the code and/or use a more human friendly number range for GUI elements. So I tend to think of them as percentages and it's a little bit like MVC on a nano-scale.

E.g. I might have a number of config files defining different height ranges for a 3D character. My tool doesn't care what the absolute values are, but it might have some special cases for say anything >80% (0.8). My model is only using normalized values.

Config A might be: min:50 - max:200
Config B: min:20 - max: 100

If my height value is internally just expressed between 0.0 .. 1.0, then I can much better work with that and computing the real absolute value (i.e. the "view" of that model parameter) is dead easy:

float val = config.min + (config.max-config.min) * normVal;

Now if there're other parameters (with their own ranges) dependent on my height param, the normalized state makes it easy to apply it to their domains (and avoid unnecessary re-mapping)...

1
  • Finally... I read you answer sometime ago but the penny has just fully dropped (especially due to keeping range out of code). Awesome, thanks.
    – Ross
    Jan 27, 2012 at 19:11
2

why one would want to normalize a float

To make as many bits as possible meaningful.

If the float is always between 0.5 and 1.0, the left-most bit can be assumed to be 1. One extra bit of precision.

7
  • but, if one had a float, then normaized it, would it gain precision?
    – Ross
    Feb 15, 2011 at 23:16
  • Indeed, floating point numbers have a finite precision. Most (I believe over half) of the presentable values are available between -1.0 and 1.0. The normalization operation itself would logically seem to lose some precision, though, so it's pointless unless you're going to do further math on the normalized values.
    – Core Xii
    Feb 15, 2011 at 23:23
  • @Ross: Yes. It would not gain accuracy, though. The point of normalizing is to do the algebra necessary to produce normalized results at every step of every floating-point operation. Un-normalized floating-point numbers require very convoluted processing to create.
    – S.Lott
    Feb 16, 2011 at 3:30
  • @S. Lott: I'm really confused by your answer. You seem to be mixing two different concepts of "normalized." The left-most bit can be assumed to be 1 for almost all values, including all values greater than 1.0. Only values very close to zero can't make the assumption. While Core Xii's comment that half of the values are between -1.0 and 1.0 is true, you lose the advantage by cramming a wider range of values into the small range of -1.0 to 1.0.
    – Mashmagar
    Feb 17, 2011 at 18:15
  • @Mashmagar: "Only values very close to zero can't make the assumption"? What? They are normalized to follow the IEEE standard for normalized floating-point values. There's no assumption. It's a rule.
    – S.Lott
    Feb 17, 2011 at 18:17
2

There is no one concept of normalizing. The normal of a plane is different from normalizing a vector, which is different from normalizing a float.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.