Project

General

Profile

« Previous | Next » 

Revision ef18eb33

Added by David Sorber about 4 years ago

Correct multiply by integer operator. Also add test cases.

View differences:

software/fixed/fixed_util.cc
#include "fixed.h"
#include "int128.h"
#define USE_INT128 1
// g++ fixed_test.cc -o fixed_test
int main(int argc, char** argv)
{
std::cout << "Fixed Type Test Util\n" << std::endl;
fixed_128_128 value;
const char* input = "-0.31415926535897932384626433832795028841";
value.parse(input);
std::cout << "[0] Value: " << value << std::endl;
value = value * 0;
std::cout << "[1] Value: " << value << std::endl;
#if 0
fixed_64_64 val;
fixed_64_64 val2;
val.parse("0.314159263538979");
......
val2 = val * 86;
std::cout << "[3] Val: " << val2 << std::endl;
std::cout << "\n--------------------------------------------------------------------\n" << std::endl;
fixed_128_128 val3;
fixed_128_128 val4;
val3.parse("0.314159263538979");
std::cout << "[1] Val: " << val3 << std::endl;
val4 = val3 * 10;
std::cout << "[2] Val: " << val4 << std::endl;
val4 = val3 * 86;
std::cout << "[3] Val: " << val4 << std::endl;
#endif
#if 0
//-------------------------------------------------------------------------

Also available in: Unified diff