1#include <Parsers/ASTSampleRatio.h>
2
3namespace DB
4{
5
6
7String ASTSampleRatio::toString(BigNum num)
8{
9 if (num == 0)
10 return "0";
11
12 static const size_t MAX_WIDTH = 40;
13
14 char tmp[MAX_WIDTH];
15
16 char * pos;
17 for (pos = tmp + MAX_WIDTH - 1; num != 0; --pos)
18 {
19 *pos = '0' + num % 10;
20 num /= 10;
21 }
22
23 ++pos;
24
25 return String(pos, tmp + MAX_WIDTH - pos);
26}
27
28
29String ASTSampleRatio::toString(Rational ratio)
30{
31 if (ratio.denominator == 1)
32 return toString(ratio.numerator);
33 else
34 return toString(ratio.numerator) + " / " + toString(ratio.denominator);
35}
36
37
38
39
40}
41