Conversion and normalization of 16-bit sample to a floating point number

  • Author or source: George Yohng
  • Created: 2007-05-02 13:34:21
code
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
float out;
signed short in;

// This code does the same as
//   out = ((float)in)*(1.0f/32768.0f);
//
// Depending on the architecture and conversion settings,
// it might be more optimal, though it is always
// advisable to check its speed against genuine
// algorithms.

((unsigned &)out)=0x43818000^in;
out-=259.0f;

Comments

Hi George Yohng

I tried it... but it's create the heavy noise!!
  • Date: 2007-09-20 17:51:12
  • By: George Yohng
Correction:
    ((unsigned &)out)=0x43818000^((unsigned short)in);
    out-=259.0f;

(needs to have a cast to 'unsigned short')