Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
605ce5e4
Commit
605ce5e4
authored
Sep 22, 2020
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify divisible_by_power_of_2
parent
085171e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
10 deletions
+3
-10
include/fmt/format-inl.h
include/fmt/format-inl.h
+3
-10
No files found.
include/fmt/format-inl.h
View file @
605ce5e4
...
@@ -1858,30 +1858,23 @@ template <class T> struct decimal_fp {
...
@@ -1858,30 +1858,23 @@ template <class T> struct decimal_fp {
int
exponent
;
int
exponent
;
};
};
//
Fast divisibility test for powers of 2 (float
).
//
Returns true iff x is divisible by pow(2, exp
).
inline
bool
divisible_by_power_of_2
(
uint32_t
x
,
int
exp
)
FMT_NOEXCEPT
{
inline
bool
divisible_by_power_of_2
(
uint32_t
x
,
int
exp
)
FMT_NOEXCEPT
{
FMT_ASSERT
(
exp
>=
1
,
""
);
FMT_ASSERT
(
exp
>=
1
,
""
);
FMT_ASSERT
(
x
!=
0
,
""
);
FMT_ASSERT
(
x
!=
0
,
""
);
#ifdef FMT_BUILTIN_CTZ
#ifdef FMT_BUILTIN_CTZ
return
FMT_BUILTIN_CTZ
(
x
)
>=
exp
;
return
FMT_BUILTIN_CTZ
(
x
)
>=
exp
;
#else
#else
if
(
exp
>=
num_bits
<
uint32_t
>
())
{
return
exp
<
num_bits
<
uint32_t
>
()
&&
x
==
((
x
>>
exp
)
<<
exp
);
return
false
;
}
return
x
==
((
x
>>
exp
)
<<
exp
);
#endif
#endif
}
}
// Fast divisibility test for powers of 2 (double).
inline
bool
divisible_by_power_of_2
(
uint64_t
x
,
int
exp
)
FMT_NOEXCEPT
{
inline
bool
divisible_by_power_of_2
(
uint64_t
x
,
int
exp
)
FMT_NOEXCEPT
{
FMT_ASSERT
(
exp
>=
1
,
""
);
FMT_ASSERT
(
exp
>=
1
,
""
);
FMT_ASSERT
(
x
!=
0
,
""
);
FMT_ASSERT
(
x
!=
0
,
""
);
#ifdef FMT_BUILTIN_CTZLL
#ifdef FMT_BUILTIN_CTZLL
return
FMT_BUILTIN_CTZLL
(
x
)
>=
exp
;
return
FMT_BUILTIN_CTZLL
(
x
)
>=
exp
;
#else
#else
if
(
exp
>=
num_bits
<
uint64_t
>
())
{
return
exp
<
num_bits
<
uint64_t
>
())
&&
x
==
((
x
>>
exp
)
<<
exp
);
return
false
;
}
return
x
==
((
x
>>
exp
)
<<
exp
);
#endif
#endif
}
}
...
...
Write
Preview
Markdown
is supported
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