mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-29 03:29:58 +02:00
This allows to replace the operands of an expression with new ones. Change-Id: I3c2d183bbdbcc43b776f7ce2a302216c52e494bd
28 lines
756 B
C++
28 lines
756 B
C++
extern "C" {
|
|
#include <assert.h>
|
|
#include <string.h>
|
|
}
|
|
|
|
#include <poincare/fraction.h>
|
|
#include "layout/fraction_layout.h"
|
|
|
|
Expression * Fraction::cloneWithDifferentOperands(Expression** newOperands,
|
|
int numberOfOperands, bool cloneOperands) {
|
|
assert(numberOfOperands == 2);
|
|
assert(newOperands != nullptr);
|
|
return new Fraction(newOperands, cloneOperands);
|
|
}
|
|
|
|
ExpressionLayout * Fraction::createLayout() {
|
|
return new FractionLayout(m_operands[0]->createLayout(), m_operands[1]->createLayout());
|
|
}
|
|
|
|
float Fraction::approximate(Context& context) {
|
|
// TODO: handle division by zero
|
|
return m_operands[0]->approximate(context)/m_operands[1]->approximate(context);
|
|
}
|
|
|
|
Expression::Type Fraction::type() {
|
|
return Expression::Type::Fraction;
|
|
}
|