[poincare] PrintFloat: change name "k_maxFloatBufferLength" -->

"k_maxFloatBufferSize"
This commit is contained in:
Émilie Feral
2019-08-09 12:04:33 +02:00
parent a2739e08cc
commit 36648ee0d8
4 changed files with 7 additions and 7 deletions

View File

@@ -17,7 +17,7 @@ public:
* At maximum, the number has 15 significant digits so, in the worst case it
* has the form -1.99999999999999ᴇ-308 (2+15+3+1+3 char) (the auto mode is
* always shorter. */
constexpr static int k_maxFloatBufferLength = 2+k_numberOfStoredSignificantDigits+k_specialECodePointByteLength+1+3+1;
constexpr static int k_maxFloatBufferSize = 2+k_numberOfStoredSignificantDigits+k_specialECodePointByteLength+1+3+1;
constexpr static int bufferSizeForFloatsWithPrecision(int numberOfSignificantDigits) {
// The worst case is -1.234ᴇ-328

View File

@@ -36,8 +36,8 @@ int FloatNode<T>::serialize(char * buffer, int bufferSize, Preferences::PrintFlo
template<typename T>
Layout FloatNode<T>::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
char buffer[PrintFloat::k_maxFloatBufferLength];
int numberOfChars = serialize(buffer, PrintFloat::k_maxFloatBufferLength, floatDisplayMode, numberOfSignificantDigits);
char buffer[PrintFloat::k_maxFloatBufferSize];
int numberOfChars = serialize(buffer, PrintFloat::k_maxFloatBufferSize, floatDisplayMode, numberOfSignificantDigits);
return LayoutHelper::String(buffer, numberOfChars);
}

View File

@@ -101,7 +101,7 @@ void PrintFloat::PrintLongWithDecimalMarker(char * buffer, int bufferLength, Lon
* in first position. When called by ConvertFloatToText, the buffer length is
* always > 0 as we asserted a minimal number of available chars. */
assert(bufferLength > 0 && decimalMarkerPosition != 0);
constexpr int tempBufferSize = PrintFloat::k_maxFloatBufferLength;
constexpr int tempBufferSize = PrintFloat::k_maxFloatBufferSize;
char tempBuffer[tempBufferSize];
int intLength = i.serialize(tempBuffer, tempBufferSize);
int firstDigitChar = UTF8Helper::CodePointIs(tempBuffer, '-') ? 1 : 0;
@@ -138,7 +138,7 @@ int PrintFloat::ConvertFloatToText(T f, char * buffer, int bufferSize,
/* Truncate the buffer if needed.
* Example: 1+1.234E-30+... in decimal mode, because we do not want the fill
* the buffer with the decimal version of 1.234E-30. */
int truncatedBufferSize = minInt(PrintFloat::k_maxFloatBufferLength, bufferSize);
int truncatedBufferSize = minInt(PrintFloat::k_maxFloatBufferSize, bufferSize);
int numberOfZerosRemoved = 0;
int requiredLength = ConvertFloatToTextPrivate(f, buffer, truncatedBufferSize, numberOfSignificantDigits, mode, &numberOfZerosRemoved, false);
@@ -146,7 +146,7 @@ int PrintFloat::ConvertFloatToText(T f, char * buffer, int bufferSize,
* display mode to scientific and decrease the number of significant digits to
* fit the buffer size. */
if (mode == Preferences::PrintFloatMode::Decimal && requiredLength >= truncatedBufferSize) {
constexpr int tempBufferSize = PrintFloat::k_maxFloatBufferLength;
constexpr int tempBufferSize = PrintFloat::k_maxFloatBufferSize;
char tempBuffer[tempBufferSize];
requiredLength = ConvertFloatToTextPrivate(f, tempBuffer, tempBufferSize, numberOfSignificantDigits, Preferences::PrintFloatMode::Scientific, &numberOfZerosRemoved, true);
if (requiredLength < truncatedBufferSize) {

View File

@@ -13,7 +13,7 @@
using namespace Poincare;
template<typename T>
void assert_float_prints_to(T a, const char * result, Preferences::PrintFloatMode mode = ScientificMode, int significantDigits = 7, int bufferSize = PrintFloat::k_maxFloatBufferLength) {
void assert_float_prints_to(T a, const char * result, Preferences::PrintFloatMode mode = ScientificMode, int significantDigits = 7, int bufferSize = PrintFloat::k_maxFloatBufferSize) {
constexpr int tagSize = 8;
unsigned char tag = 'O';
char taggedBuffer[250+2*tagSize];