Defect in long map() function?--integer scaling

Works the way the original author intended it to work

Please point out to me why you draw that conclusion.

This is from the documentation...

Fractional remainders are truncated, and are not rounded or averaged

If the plus-ones are included, the net effect is that the returned value is rounded. If the plus-ones are not included, the net effect is that returned value is truncated; which matches the description in the documentation. Note: I only tested positive parameter values. I don't know how map behaves for negative values.

I admit I assumed the person who wrote map is also the person who wrote the documentation. If they aren't the same person then I have no idea what the original author intended.

How does a template help?

By always using the best suited datatype in the arithmetics. Just a small reply to the comments about inefficiency working with longs even if you only need bytes.

Ah! Got it! Given that most values are going to be scaled from 0-1023, that's a great idea!