mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-26 09:10:48 +01:00
[poincare] WirteToText always use MultiplicationSign and Layouts use
MiddleDot Change-Id: I4ffff6e6634deba376f083ef382e6bec0ff0883b
This commit is contained in:
@@ -81,7 +81,7 @@ private:
|
||||
constexpr static int k_maxComplexBufferLength = 14+14+7+1;
|
||||
/* convertComplexToText and convertFloatToTextPrivate return the string length
|
||||
* of the buffer (does not count the 0 last char)*/
|
||||
int convertComplexToText(char * buffer, int bufferSize, Expression::FloatDisplayMode floatDisplayMode, Expression::ComplexFormat complexFormat) const;
|
||||
int convertComplexToText(char * buffer, int bufferSize, Expression::FloatDisplayMode floatDisplayMode, Expression::ComplexFormat complexFormat, char multiplicationSign) const;
|
||||
static int convertFloatToTextPrivate(T f, char * buffer, int numberOfSignificantDigits, Expression::FloatDisplayMode mode);
|
||||
ExpressionLayout * createPolarLayout(Expression::FloatDisplayMode floatDisplayMode) const;
|
||||
ExpressionLayout * createCartesianLayout(Expression::FloatDisplayMode floatDisplayMode) const;
|
||||
|
||||
@@ -200,7 +200,7 @@ T Complex<T>::toScalar() const {
|
||||
|
||||
template <class T>
|
||||
int Complex<T>::writeTextInBuffer(char * buffer, int bufferSize) const {
|
||||
return convertComplexToText(buffer, bufferSize, Preferences::sharedPreferences()->displayMode(), Preferences::sharedPreferences()->complexFormat());
|
||||
return convertComplexToText(buffer, bufferSize, Preferences::sharedPreferences()->displayMode(), Preferences::sharedPreferences()->complexFormat(), Ion::Charset::MultiplicationSign);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@@ -253,7 +253,7 @@ Complex<U> * Complex<T>::templatedApproximate(Context& context, Expression::Angl
|
||||
}
|
||||
|
||||
template <class T>
|
||||
int Complex<T>::convertComplexToText(char * buffer, int bufferSize, Expression::FloatDisplayMode displayMode, Expression::ComplexFormat complexFormat) const {
|
||||
int Complex<T>::convertComplexToText(char * buffer, int bufferSize, Expression::FloatDisplayMode displayMode, Expression::ComplexFormat complexFormat, char multiplicationSpecialChar) const {
|
||||
assert(displayMode != Expression::FloatDisplayMode::Default);
|
||||
int numberOfChars = 0;
|
||||
if (std::isnan(m_a) || std::isnan(m_b)) {
|
||||
@@ -263,7 +263,7 @@ int Complex<T>::convertComplexToText(char * buffer, int bufferSize, Expression::
|
||||
if (r() != 1 || th() == 0) {
|
||||
numberOfChars = convertFloatToText(r(), buffer, bufferSize, k_numberOfSignificantDigits, displayMode);
|
||||
if (r() != 0 && th() != 0 && bufferSize > numberOfChars+1) {
|
||||
buffer[numberOfChars++] = Ion::Charset::MiddleDot;
|
||||
buffer[numberOfChars++] = multiplicationSpecialChar;
|
||||
// Ensure that the string is null terminated even if buffer size is to small
|
||||
buffer[numberOfChars] = 0;
|
||||
}
|
||||
@@ -278,7 +278,7 @@ int Complex<T>::convertComplexToText(char * buffer, int bufferSize, Expression::
|
||||
}
|
||||
numberOfChars += convertFloatToText(th(), buffer+numberOfChars, bufferSize-numberOfChars, k_numberOfSignificantDigits, displayMode);
|
||||
if (bufferSize > numberOfChars+3) {
|
||||
buffer[numberOfChars++] = Ion::Charset::MiddleDot;
|
||||
buffer[numberOfChars++] = multiplicationSpecialChar;
|
||||
buffer[numberOfChars++] = Ion::Charset::IComplex;
|
||||
buffer[numberOfChars++] = ')';
|
||||
buffer[numberOfChars] = 0;
|
||||
@@ -297,7 +297,7 @@ int Complex<T>::convertComplexToText(char * buffer, int bufferSize, Expression::
|
||||
}
|
||||
if (m_b != 1 && m_b != -1 && m_b != 0) {
|
||||
numberOfChars += convertFloatToText(m_b, buffer+numberOfChars, bufferSize-numberOfChars, k_numberOfSignificantDigits, displayMode);
|
||||
buffer[numberOfChars++] = Ion::Charset::MiddleDot;
|
||||
buffer[numberOfChars++] = multiplicationSpecialChar;
|
||||
}
|
||||
if (m_b == -1 && bufferSize > numberOfChars+1) {
|
||||
buffer[numberOfChars++] = '-';
|
||||
@@ -472,7 +472,7 @@ ExpressionLayout * Complex<T>::createPolarLayout(Expression::FloatDisplayMode fl
|
||||
template <class T>
|
||||
ExpressionLayout * Complex<T>::createCartesianLayout(Expression::FloatDisplayMode floatDisplayMode) const {
|
||||
char buffer[k_maxComplexBufferLength];
|
||||
int numberOfChars = convertComplexToText(buffer, k_maxComplexBufferLength, floatDisplayMode, Expression::ComplexFormat::Cartesian);
|
||||
int numberOfChars = convertComplexToText(buffer, k_maxComplexBufferLength, floatDisplayMode, Expression::ComplexFormat::Cartesian, Ion::Charset::MiddleDot);
|
||||
return new StringLayout(buffer, numberOfChars);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user