Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
b688f9bc
Commit
b688f9bc
authored
May 22, 2014
by
Tomasz Wlostowski
Committed by
Maciej Suminski
May 22, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
math_util: speed up rescaling on 64-bit platforms by using native 128-bit types
parent
655721d9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
math_util.cpp
common/math/math_util.cpp
+8
-3
No files found.
common/math/math_util.cpp
View file @
b688f9bc
...
...
@@ -27,17 +27,21 @@
#include <cstdlib>
#include <climits>
#include <math/math_util.h>
#include <stdint.h>
template
<>
template
<>
int
rescale
(
int
aNumerator
,
int
aValue
,
int
aDenominator
)
{
return
(
int
)
(
(
int64_t
)
aNumerator
*
(
int64_t
)
aValue
/
(
int64_t
)
aDenominator
);
}
template
<>
template
<>
int64_t
rescale
(
int64_t
aNumerator
,
int64_t
aValue
,
int64_t
aDenominator
)
{
#ifdef __x86_64__
return
(
(
__int128_t
)
aNumerator
*
(
__int128_t
)
aValue
)
/
aDenominator
;
#else
int64_t
r
=
0
;
int64_t
sign
=
(
(
aNumerator
<
0
)
?
-
1
:
1
)
*
(
aDenominator
<
0
?
-
1
:
1
)
*
(
aValue
<
0
?
-
1
:
1
);
...
...
@@ -84,4 +88,5 @@ int64_t rescale( int64_t aNumerator, int64_t aValue, int64_t aDenominator )
return
t1
*
sign
;
}
#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