That code works with any fixed-width type, and meets all of the criteria you gave.

However, it did just occur to me that there's a way to eliminate the heap due to the contraint that the non-singletons appear an even number of times. This forum should definitely have spoiler tags!

[spoiler]`int findSingleton(int array[]) {`

int result = 0;

for(int value : array)

result ^= value;

return result;

}

[/spoiler]