#include #include #include extern "C" { #include } #include namespace Poincare { Expression::Type Randint::type() const { return Type::Randint; } Expression * Randint::clone() const { Randint * a = new Randint(m_operands, true); return a; } template Evaluation * Randint::templateApproximate(Context & context, AngleUnit angleUnit) const { Evaluation * aInput = operand(0)->privateApproximate(T(), context, angleUnit); Evaluation * bInput = operand(1)->privateApproximate(T(), context, angleUnit); T a = aInput->toScalar(); T b = bInput->toScalar(); delete aInput; delete bInput; if (std::isnan(a) || std::isnan(b) || a != std::round(a) || b != std::round(b) || a > b) { return new Complex(Complex::Undefined()); } T result = std::floor(Random::random()*(b+1.0-a)+a); return new Complex(result); } }