Skip to main content
added 2 characters in body
Source Link
AShelly
  • 4.7k
  • 1
  • 22
  • 38

C, 66 48

Original:

int l(long*s){return strlen(s)/((*s&~(-1L<<56))!=0x656c676f6f67);}

Using OSX gcc,
l("duck"); returns 4,
l("google"); causes Floating point exception: 8.

On other platforms, the constants may need to be adjusted for endianness.

Shorter:

less trickyness, same errorresults.

 l(int*s){return strlen(s)/!!strcmp(s,"Google");}

C, 66 48

Original:

int l(long*s){return strlen(s)/((*s&~(-1L<<56))!=0x656c676f6f67);}

Using OSX gcc,
l("duck"); returns 4,
l("google"); causes Floating point exception: 8.

On other platforms, the constants may need to be adjusted for endianness.

Shorter:

less trickyness, same error.

 l(int*s){return strlen(s)/!!strcmp(s,"Google");}

C, 66 48

Original:

int l(long*s){return strlen(s)/((*s&~(-1L<<56))!=0x656c676f6f67);}

Using OSX gcc,
l("duck"); returns 4,
l("google"); causes Floating point exception: 8.

On other platforms, the constants may need to be adjusted for endianness.

Shorter:

less trickyness, same results.

 l(int*s){return strlen(s)/!!strcmp(s,"Google");}
shoritfy
Source Link
AShelly
  • 4.7k
  • 1
  • 22
  • 38

C, 6666 48

Original:

int l(long*s){return strlen(s)/((*s&~(-1L<<541L<<56))!=0x656c676f6f67);}

Using OSX gcc,
l("duck"); returns 4,
l("google"); causes Floating point exception: 8.

On other platforms, the constants may need to be adjusted for endianness.

Shorter:

less trickyness, same error.

 l(int*s){return strlen(s)/!!strcmp(s,"Google");}

C, 66

int l(long*s){return strlen(s)/((*s&~(-1L<<54))!=0x656c676f6f67);}

Using OSX gcc,
l("duck"); returns 4,
l("google"); causes Floating point exception: 8.

On other platforms, the constants may need to be adjusted for endianness.

C, 66 48

Original:

int l(long*s){return strlen(s)/((*s&~(-1L<<56))!=0x656c676f6f67);}

Using OSX gcc,
l("duck"); returns 4,
l("google"); causes Floating point exception: 8.

On other platforms, the constants may need to be adjusted for endianness.

Shorter:

less trickyness, same error.

 l(int*s){return strlen(s)/!!strcmp(s,"Google");}
Source Link
AShelly
  • 4.7k
  • 1
  • 22
  • 38

C, 66

int l(long*s){return strlen(s)/((*s&~(-1L<<54))!=0x656c676f6f67);}

Using OSX gcc,
l("duck"); returns 4,
l("google"); causes Floating point exception: 8.

On other platforms, the constants may need to be adjusted for endianness.