Three wrongs make a right

  • Authors:
  • J. F. Blinn

  • Affiliations:
  • California Inst. of Technol., Pasadena, CA

  • Venue:
  • IEEE Computer Graphics and Applications
  • Year:
  • 1995

Quantified Score

Hi-index 0.00

Visualization

Abstract

When dealing with graphics operations that must be fast (like the inner loops of rendering algorithms), I usually like to do calculations with fixed-point arithmetic (that is, scaled integers) rather than floating point arithmetic. The exact scaling factor used can have some interesting effects on the speed and errors in the calculation. In this article, I'll give some titbits I've discovered or picked up from others about this. In particular, I'll talk about some of the advantages of using odd numbers of the form 2n-1 as scaling factors. The motivation for this discussion is the desire to do arithmetic on pixel values: red, green, blue, or alpha. These values are in the range 0...1, so all numbers you see here are positive. In the discussion that follows, I'll use floating point as a testbed and as scaffolding to derive integer formulas. All final calculations take place using only integer arithmetic