43 const char fractionPoint) :
digits(digits)
76 const char *text =
"base ";
174 if (a == 0.0 && b == 0.0)
191 if (a != 0.0 && b > 0.0)
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);
278 int actualdigits =
static_cast<
int>(
trunc(temp1 + 3e-15
));
279 int padding = fragdigits - (fin == 1 ? actualdigits : 0) - 1;
282 while (padding-- > 0)
318 static const char *alphaNumerics =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
319 unsigned int count = 0;
320 char *chars =
new char[128];
327 *chars++ = alphaNumerics[intremainder];
329 }
while (value >= 1.0);
331 unsigned int n = count;
332 unsigned int q = digits;
335 while (n-- != 0 && q-- != 0)
352 unsigned int pos = 0;
368 addition = (*text -
'0') * 1.0;
372 addition = (*text -
'A' + 10) * 1.0;
376 addition = (*text -
'a' + 10) * 1.0;
393 *end =
const_cast<
char *>(text);
398 double fraction = 0.0;
399 double divisor = 1.0;
417 addition = (*text -
'0') * 1.0;
421 addition = (*text -
'A' + 10) * 1.0;
425 addition = (*text -
'a' + 10) * 1.0;
442 if (*text ==
'e' || *text ==
'E')
448 double sign = *text ==
'+' ? 1.0 : *text ==
'-' ? -1.0 : 0.0;
466 addition = (*text -
'0') * 1.0;
470 addition = (*text -
'A' + 10) * 1.0;
474 addition = (*text -
'a' + 10) * 1.0;
496 *end =
const_cast<
char *>(text);
498 double dnumber = (integer + (fraction / divisor));
virtual bool IsNegative()=0
void Append(const char c)
~PositionalNumeralSystem()
bool IsDigit(char *digit)
virtual void SetFractionPoint(const char fractionPoint)
const char * GetText(double number) const
virtual const char * GetPrefix()
PositionalNumeralSystem(unsigned int base, unsigned int digits, const char fractionPoint)
double trunc(double x)
Truncate function.
virtual const char * GetName()
virtual bool IsInfinite()=0
double pow(double x, double y)
Expontation function.
void IntegerToBuffer(double value, unsigned int digits, int *outdigits) const
bool RemoveTrailing(const char c)
CharBuffer(unsigned int size)
Initialize while allocating specified amount of memory.
double creal(complex z)
Real part of complex number.
bool Is(const char *string) const
Compare content of CharBuffer with string)
double round(double x)
Round function.
void Append(const char *source)
const char * GetSpecialCase(Number *number)
double fmod(double x, double y)
Return x mod y in exact arithmetic.
virtual const char * GetText(Number *number)=0
RealNumber(unsigned int i)
virtual const char GetFractionPoint()
virtual bool IsNotImplemented()=0
virtual const char * GetText(Number *number)
Base class for all numeral systems with a positional notation.
Represent a real number with 15 significant digits.
virtual double GetRealValue()=0
double cimag(complex z)
Imaginary part of complex number.
double fabs(double x)
Returns the absolute value of x.
double log2p(double x, double y)
virtual unsigned int GetDigits()
Represent a complex number with 2 components of 15 significant digits.
virtual Number * Parse(const char *text, unsigned int *length, char **end)
complex GetComplexValue() const
virtual void SetDigits(unsigned int digits)
int StrLen(const char *string)
Get the length of a null terminated string.
void Copy(CharBuffer *buf)
Base class for all numeral systems.
DecimalSystem(unsigned int digits)
Encapsulate an character array which can be used as a string.
void EnsureSize(unsigned int size)
Ensure a memory block of specified size is allocated.