Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Broadcom Open-Sources Wireless Drivers

Name: Anonymous 2010-09-09 15:26

The ternary operator is dissapointed.


/*
Description: This function saturate input 32 bit number into a 16 bit number.
If input number is greater than 0x7fff then output is saturated to 0x7fff.
else if input number is less than 0xffff8000 then output is saturated to 0xffff8000
else output is same as input.
*/
int16 qm_sat32(int32 op)
{
    int16 result;
    if (op > (int32) 0x7fff) {
        result = 0x7fff;
    } else if (op < (int32) 0xffff8000) {
        result = (int16) (0x8000);
    } else {
        result = (int16) op;
    }
    return result;
}

Name: Anonymous 2010-09-12 11:10

int16 qm_sat32(int32 op)
{
  if op > int16.MAX_VALUE:
    return int16.MAX_VALUE
  elif op < int16.MIN_VALUE:
    return int16.MIN_VALUE
  else:
    return (int16) op
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List