Files
Upsilon/apps/graph/values/float_to_string.h
Émilie Feral 2b8df283e2 [apps/graph/values] Add a parameter in float_to_string to cap the number of significative number
Change-Id: I8406a910c176da13147fe0235b183ea22dc4faa0
2016-10-12 17:39:53 +02:00

27 lines
1.0 KiB
C++

#ifndef GRAPH_FLOAT_TO_STRING_H
#define GRAPH_FLOAT_TO_STRING_H
#include <assert.h>
#include <math.h>
namespace FloatToString {
enum Mode {
SCIENTIFIC, DECIMAL
};
/* This function prints the int i in the buffer with a '.' at the position
* specified by the decimalMarkerPosition. It starts printing at the end of the
* buffer and print from right to left. The integer given should be of the right
* length to be written in bufferLength chars. If the integer is to small, the
* empty chars on the left side are completed with '0'. If the integer is too
* big, the printing stops when no more empty chars are available without
* returning any warning. */
void printBase10IntegerWithDecimalMarker(char * buffer, int bufferLength, int i, int decimalMarkerPosition);
/* The parameter 'mode' refers to the way to display float 'scientific' or
* 'decimal'. The code only handles 'scientific' so far. */
void convertFloatToText(float f, char * buffer, int maxNumberOfChar, int numberOfDigitsInMantissa, Mode mode = SCIENTIFIC);
}
#endif