[poincare] Handle inf and nan when convert float in string

Change-Id: I2121a8030d044984235e48ad50a3c6ec9e06c31e
This commit is contained in:
Émilie Feral
2016-10-26 12:23:41 +02:00
parent 0dffa59352
commit 2eae7c43ff

View File

@@ -67,9 +67,16 @@ void Float::convertFloatToText(char * buffer, int bufferSize,
* worst case has the form -1.999999e-38 (7+6+1 char). */
assert(bufferSize > 6 + numberOfDigitsInMantissa);
// TO DO: if (isinf(m_float)) {
float maximalFloat = 3.4f*powf(10, 38);
if (m_float > maximalFloat || m_float < -maximalFloat) {
if (isinf(m_float)) {
buffer[0] = m_float > 0 ? '+' : '-';
buffer[1] = 'I';
buffer[2] = 'n';
buffer[3] = 'f';
buffer[4] = 0;
return;
}
if (isnan(m_float)) {
buffer[0] = 'N';
buffer[1] = 'a';
buffer[2] = 'N';