- Added clog2 function

- negative numbers can now be displayed in 2's compliment binary
This commit is contained in:
Joe Crop
2022-12-06 11:10:01 -08:00
parent 42d8fea8c6
commit fc95028b57
20 changed files with 97 additions and 9 deletions

View File

@@ -220,6 +220,14 @@ namespace Poincare
Expression shallowReduce(ExpressionNode::ReductionContext reductionContext);
};
class CeilingLog2 final : public Expression {
public:
CeilingLog2(const BinaryOperationNode<32> *n) : Expression(n) {}
static CeilingLog2 Builder(Expression child1) { return TreeHandle::FixedArityBuilder<CeilingLog2, BinaryOperationNode<32> >({child1}); }
static constexpr Expression::FunctionHelper s_functionHelper = Expression::FunctionHelper("clog2", 1, &UntypedBuilderOneChild<CeilingLog2>);
Expression shallowReduce(ExpressionNode::ReductionContext reductionContext);
};
} // namespace Poincare
#endif

View File

@@ -36,6 +36,7 @@ class Expression : public TreeHandle {
friend class BitsClearExplicit;
friend class BitSet;
friend class Ceiling;
friend class CeilingLog2;
friend class CommonLogarithm;
template<typename T>
friend class ComplexNode;

View File

@@ -65,6 +65,7 @@ public:
BinomialCoefficient,
BinomPDF,
Ceiling,
CeilingLog2,
ComplexArgument,
Conjugate,
Derivative,

View File

@@ -169,6 +169,7 @@ public:
static Integer LogicalBitFlip(const Integer &a, const Integer &bit);
static Integer Truncate(const Integer &a, const Integer &num_bits);
static Integer TwosComplementToBits(const Integer &a, const Integer &num_bits);
static Integer CeilingLog2(const Integer &a);
// Derived expression builder
static Expression CreateMixedFraction(const Integer & num, const Integer & denom);