Numworks Epsilon  1.4.1
Graphing Calculator Operating System
undefined.cpp
Go to the documentation of this file.
1 #include <poincare/undefined.h>
2 extern "C" {
3 #include <math.h>
4 }
5 #include "layout/string_layout.h"
6 
7 namespace Poincare {
8 
10  return Type::Undefined;
11 }
12 
14  return new Undefined();
15 }
16 
17 int Undefined::polynomialDegree(char symbolName) const {
18  return -1;
19 }
20 
21 template<typename T> Complex<T> * Undefined::templatedApproximate(Context& context, AngleUnit angleUnit) const {
22  return new Complex<T>(Complex<T>::Float(NAN));
23 }
24 
25 ExpressionLayout * Undefined::privateCreateLayout(PrintFloat::Mode floatDisplayMode, ComplexFormat complexFormat) const {
26  char buffer[16];
27  int numberOfChars = PrintFloat::convertFloatToText<float>(NAN, buffer, 16, 1, floatDisplayMode);
28  return new StringLayout(buffer, numberOfChars);
29 }
30 
31 int Undefined::writeTextInBuffer(char * buffer, int bufferSize, int numberOfSignificantDigits) const {
32  if (bufferSize == 0) {
33  return -1;
34  }
35  return strlcpy(buffer, "undef", bufferSize);
36 }
37 
38 }
39 
#define NAN
Definition: math.h:30
Expression * clone() const override
Definition: undefined.cpp:13
size_t strlcpy(char *dst, const char *src, size_t len)
Definition: strlcpy.c:3
int writeTextInBuffer(char *buffer, int bufferSize, int numberOfSignificantDigits=PrintFloat::k_numberOfStoredSignificantDigits) const override
Definition: undefined.cpp:31
int polynomialDegree(char symbolName) const override
Definition: undefined.cpp:17
static Complex< T > Float(T x)
Definition: complex.cpp:23
Type type() const override
Definition: undefined.cpp:9
friend class Undefined
Definition: expression.h:17