Skip to main content
added 6 characters in body
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

C and other languages with integer division, 15.204 14.644 1414.084 11.084864

unsigned char toUpper(unsigned char c){
    return c - ((c/97) &^ (1 - c/123)) << 5;
}

unsigned char toLower(unsigned char c){
    return c + ((c/65) &^ (1 - c/91)) << 5;
}

C and other languages with integer division, 15.204 14.644 14.084

unsigned char toUpper(unsigned char c){
    return c - ((c/97) & (1 - c/123)) << 5;
}

unsigned char toLower(unsigned char c){
    return c + ((c/65) & (1 - c/91)) << 5;
}

C and other languages with integer division, 15.204 14.644 14.084 11.864

unsigned char toUpper(unsigned char c){
    return c - ((c/97) ^ (c/123)) << 5;
}

unsigned char toLower(unsigned char c){
    return c + ((c/65) ^ (c/91)) << 5;
}
Source Link
Martin Ender
  • 197.2k
  • 67
  • 447
  • 975

C and other languages with integer division, 15.204 14.644 14.084

unsigned char toUpper(unsigned char c){
    return c - ((c/97) & (1 - c/123)) << 5;
}

unsigned char toLower(unsigned char c){
    return c + ((c/65) & (1 - c/91)) << 5;
}