Skip to content

Commit 5fbe238

Browse files
committed
Add parsing of precision argument
1 parent 1de7dbc commit 5fbe238

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

include/boost/decimal/format.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,20 @@ constexpr auto parse_impl(ParseContext &ctx)
124124
bool is_upper = false;
125125
int padding_digits = 0;
126126

127-
if (*it != '}')
127+
// If there is a . then we need to capture the precision argument
128+
if (*it == '.')
129+
{
130+
++it;
131+
ctx_precision = 0;
132+
while (it != ctx.end() && *it >= '0' && *it <= '9')
133+
{
134+
ctx_precision = ctx_precision * 10 + (*it - '0');
135+
++it;
136+
}
137+
}
138+
139+
// Lastly we capture the format to include if it's upper case
140+
if (it != ctx.end() && *it != '}')
128141
{
129142
switch (*it)
130143
{

0 commit comments

Comments
 (0)