Base class for all numeral systems with a positional notation.
More info on positional notation is available at Wikipedia: https://wikipedia.org/wiki/Positional_notation
Definition at line 41 of file ntextp.h.
const char * PositionalNumeralSystem::GetText |
( |
Number * |
number | ) |
|
|
virtual |
Implements NumeralSystem.
Reimplemented in DecimalSystem.
Definition at line 157 of file ntextp.cpp.
References CharBuffer::Append(), NumeralSystem::buf, CharBuffer::CharBuffer(), cimag(), CharBuffer::Copy(), creal(), CharBuffer::Empty(), ComplexNumber::GetComplexValue(), Number::GetRealValue(), GetSpecialCase(), CharBuffer::GetString(), GetText(), nsysreal, and Number::system.
174 if (a == 0.0 && b == 0.0)
191 if (a != 0.0 && b > 0.0)
double cimag(complex z)
Imaginary part of complex number.
void Append(const char *source)
const char * GetSpecialCase(Number *number)
double creal(complex z)
Real part of complex number.
virtual const char * GetText(Number *number)
virtual double GetRealValue()=0
Represent a complex number with 2 components of 15 significant digits.
void Copy(CharBuffer *buf)
Encapsulate an character array which can be used as a string.
const char * PositionalNumeralSystem::GetText |
( |
double |
number | ) |
const |
|
private |
Definition at line 208 of file ntextp.cpp.
References CharBuffer::Append(), baseDouble, NumeralSystem::buf, digits, CharBuffer::Empty(), fabs(), FloatUnion64::floatingPoint, fractionPoint, CharBuffer::GetString(), IntegerToBuffer(), CharBuffer::Is(), FloatUnion64::IsInf(), log2p(), pow(), CharBuffer::RemoveTrailing(), round(), and trunc().
Referenced by GetText().
217 double dnumber = number;
225 double expacc = expbor > 0.0 ? 4e-14 : -1e-15;
226 double expborder =
trunc(expbor + expacc);
235 if (expborder >= bordermax || expborder <= bordermin)
241 if (dexp > 15 || dexp < -15)
253 exponent =
static_cast<int>(dexp);
258 double acc = exponent > 0 ? 15 : -15;
265 double intvalue =
trunc(dnumber + rounding);
268 int fragdigits =
digits - intdigits + (intvalue < 1.0 ? 1 : 0);
277 bool fin = !temp2.
IsInf();
278 int actualdigits =
static_cast<int>(
trunc(temp1 + 3e-15));
279 int padding = fragdigits - (fin == 1 ? actualdigits : 0) - 1;
282 while (padding-- > 0)
double log2p(double x, double y)
void IntegerToBuffer(double value, unsigned int digits, int *outdigits) const
bool RemoveTrailing(const char c)
bool Is(const char *string) const
Compare content of CharBuffer with string)
void Append(const char *source)
double pow(double x, double y)
Expontation function.
double fabs(double x)
Returns the absolute value of x.
double trunc(double x)
Truncate function.
double round(double x)
Round function.