Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef __PRECISION_HPP__
- #define __PRECISION_HPP__
- #include <iomanip>
- #include "base.hpp"
- using namespace std;
- class PrecisionOp : public Op {
- private: double value;
- int numDecimals;
- public: PrecisionOp() {};
- PrecisionOp(double userVal, int inputDecimals) {
- value = userVal;
- numDecimals = inputDecimals;
- }
- string stringify() {
- ostringstream strStream;
- strStream << fixed << setprecision(numDecimals) << value;
- string returnStr = strStream.str();
- return returnStr;
- }
- };
- class PrecisionRand : public Rand {
- private: double value;
- int numDecimals;
- public: PrecisionRand() {};
- PrecisionRand(int amtPrecision) {
- value = rand() % 100;
- numDecimals = amtPrecision;
- }
- string stringify() {
- ostringstream strStream;
- strStream << fixed << setprecision(numDecimals) << value;
- string returnStr = strStream.str();
- return returnStr;
- }
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement