From 30a1a1f0eb5099a378766cd16cccd10df34f5406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9a=20Saviot?= Date: Fri, 26 Apr 2019 10:44:13 +0200 Subject: [PATCH] [ion/bench] In crc, use print_float instead of print_int --- ion/src/device/bench/command/crc.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ion/src/device/bench/command/crc.cpp b/ion/src/device/bench/command/crc.cpp index 9d82d1144..117ebe135 100644 --- a/ion/src/device/bench/command/crc.cpp +++ b/ion/src/device/bench/command/crc.cpp @@ -1,7 +1,8 @@ #include "command.h" #include -#include +#include #include +#include namespace Ion { namespace Device { @@ -52,8 +53,10 @@ void CRC(const char * input) { constexpr int bufferSize = 4+10+1; // crc is a uint32_t so 10 digits long. char buffer[bufferSize] = {'C', 'R', 'C', '=', 0}; - constexpr int precision = 10; - Poincare::PrintFloat::convertFloatToText(crc, buffer+4, bufferSize - 4, precision, Poincare::Preferences::PrintFloatMode::Decimal); + int wantedLength = std::log10(crc*1.0)+1; + assert(wantedLength < bufferSize - 4); + Poincare::PrintInt::PadIntInBuffer(crc, buffer+4, wantedLength); + buffer[4+wantedLength] = 0; reply(buffer); }