Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Philip Trettner
typed-geometry
Commits
9ffa85d5
Commit
9ffa85d5
authored
Nov 25, 2020
by
Julius Nehring-Wirxel
Browse files
Print fixed_(u)int as decimal instead of hex
parent
f7287eea
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/typed-geometry/functions/std/io.hh
View file @
9ffa85d5
...
...
@@ -73,37 +73,31 @@ std::basic_ostream<CharT, StreamTraits>& operator<<(std::basic_ostream<CharT, St
template
<
int
w
,
class
CharT
,
class
StreamTraits
>
std
::
basic_ostream
<
CharT
,
StreamTraits
>&
operator
<<
(
std
::
basic_ostream
<
CharT
,
StreamTraits
>&
out
,
fixed_uint
<
w
>
const
&
val
)
{
constexpr
const
char
*
hex_map
=
"0123456789ABCDEF"
;
auto
ss
=
detail
::
temp_sstream
(
out
);
ss
<<
"u"
<<
64
*
w
<<
"("
;
ss
<<
"0x"
;
for
(
auto
wi
=
w
-
1
;
wi
>=
0
;
--
wi
)
for
(
auto
i
=
15
;
i
>=
0
;
--
i
)
{
const
u64
idx
=
(
val
.
d
[
wi
]
>>
(
i
*
4
))
&
0xF
;
ss
<<
hex_map
[
idx
];
}
ss
<<
")"
;
return
out
<<
ss
.
str
();
char
buf
[
w
*
20
+
1
];
auto
const
end
=
buf
+
sizeof
(
buf
);
auto
begin
=
end
;
*
(
--
begin
)
=
'\0'
;
auto
u
=
val
;
while
(
u
>
0
)
{
auto
const
n
=
u64
(
u
%
10
);
u
/=
10
;
*
(
--
begin
)
=
'0'
+
n
;
}
if
(
begin
+
1
==
end
)
*
(
--
begin
)
=
'0'
;
return
out
<<
begin
;
}
template
<
int
w
,
class
CharT
,
class
StreamTraits
>
std
::
basic_ostream
<
CharT
,
StreamTraits
>&
operator
<<
(
std
::
basic_ostream
<
CharT
,
StreamTraits
>&
out
,
fixed_int
<
w
>
const
&
val
)
{
constexpr
const
char
*
hex_map
=
"0123456789ABCDEF"
;
auto
ss
=
detail
::
temp_sstream
(
out
);
ss
<<
"i"
<<
64
*
w
<<
"("
;
ss
<<
"0x"
;
for
(
auto
wi
=
w
-
1
;
wi
>=
0
;
--
wi
)
for
(
auto
i
=
15
;
i
>=
0
;
--
i
)
{
const
u64
idx
=
(
val
.
d
[
wi
]
>>
(
i
*
4
))
&
0xF
;
ss
<<
hex_map
[
idx
];
}
ss
<<
")"
;
return
out
<<
ss
.
str
();
if
(
val
<
0
)
{
out
<<
'-'
;
return
out
<<
fixed_uint
<
w
>
(
-
val
);
}
return
out
<<
fixed_uint
<
w
>
(
val
);
}
//
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment