This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Testing the PRNG "Multiply with Carry" by George Marsaglia: | |
* | |
* http://en.wikipedia.org/wiki/Multiply-with-carry | |
* | |
* g++ -std=c++11 -Wall -Werror -Wextra -pedantic -pedantic-errors randMulCarry.cpp -o randMulCarry | |
*/ | |
#include <algorithm> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Test of getting the next/previous powers of 2 | |
* | |
* g++ -std=c++11 -Wall -Werror -Wextra -pedantic -pedantic-errors pow2.cpp -o pow2 | |
*/ | |
#include <iostream> | |
#include <sstream> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// testing fixed point numbers | |
// g++ -std=c++11 -W -Wall -Werror -Wextra fixed.cpp -o fixed | |
#include <iostream> | |
#include <cstdint> | |
#include <limits> | |
#include <typeinfo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* testing a log function */ | |
// g++ -std=c++11 -pedantic -Wall -Werror -Wextra -W fastlog.cpp -o fastlog | |
#include <cmath> | |
#include <iomanip> | |
#include <limits> | |
#include <iostream> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
// g++ -std=c++11 -pedantic -Wall -Werror -Wextra factorial.cpp -o factorial | |
template <typename type> | |
constexpr type constFactorial( type n ) { | |
return (n > 1) ? n * constFactorial( n - 1 ) : n; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Testing the result of a dot product | |
* | |
* gcc -std=c99 -Wall -Werror -Wextra -pedantic -pedantic-errors dotprod.c -o dotprod | |
*/ | |
#include <stdio.h> | |
typedef struct vector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Bignum multiplication | |
* | |
* g++ -std=c++11 -Wall -Wextra -Werror -pedantic-errors bn_mul.cpp -o bn_mul | |
* | |
* usage: ./bn_mul 123456789 987654321 | |
*/ | |
#include <cstring> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Bignum Addition Test | |
* g++ -std=c++11 -Wall -Werror -Wextra -pedantic -pedantic-errors bignum_add.cpp -o bignum_add | |
*/ | |
#include <utility> // std::move | |
#include <string> // std::string | |
#include <iostream> // std::cout | |
#include <cstdint> // uint8_t, uint16_t, UINT8_MAX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Simple test to get the average of an arbitrary set of numbers | |
* | |
* g++ -std=c++11 -Wall -Werror -Wextra -pedantic -pedantic-errors avgnum.cpp -o avgnum | |
*/ | |
#include <iostream> | |
#define TEST_NUM 42 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Test to automatically get the aspect ratio of a display | |
// g++ -std=c++11 -pedantic-errors -Wall -Wextra -Werror aspect.cpp -o aspect | |
#include <cmath> | |
#include <iostream> | |
template <typename int_t> | |
int_t gcd(int_t a, int_t b) { | |
while (b) { |