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
Franck Dary
macaon
Commits
0ab37e18
Commit
0ab37e18
authored
Mar 16, 2021
by
Franck Dary
Browse files
Added test for overflow
parent
38bfb975
Changes
1
Hide whitespace changes
Inline
Side-by-side
common/src/util.cpp
View file @
0ab37e18
...
...
@@ -12,8 +12,8 @@ float util::long2float(long l)
long
util
::
float2long
(
float
f
)
{
float
res
=
f
*
util
::
float2longScale
;
if
(
f
!=
0
and
res
/
f
!=
util
::
float2longScale
)
util
::
myTh
ro
w
(
fmt
::
format
(
"Float '{}' is too big to be converted to long
"
,
f
));
if
(
f
!=
0
and
std
::
round
(
res
/
f
)
!=
std
::
round
(
util
::
float2longScale
)
)
util
::
er
ro
r
(
fmt
::
format
(
"Float '{}' is too big to be converted to long
({}!={})"
,
f
,
res
/
f
,
util
::
float2longScale
));
return
res
;
}
...
...
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