Nikhar's revision. Removed MSVC compiler warnings. Changed some casts to template parameter T. Added a high-precision gamma test.