MRPT
1.9.9
Main Page
Related Pages
Modules
+
Namespaces
Namespace List
+
Namespace Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
+
Variables
_
a
b
c
d
e
g
h
i
l
m
n
p
r
s
t
u
v
w
+
Typedefs
_
a
c
f
m
o
p
r
s
t
v
+
Enumerations
e
f
g
m
n
p
s
t
v
+
Enumerator
a
b
c
d
e
f
i
k
l
m
n
o
p
r
s
t
u
v
w
+
Classes
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
+
Enumerations
a
f
j
l
m
p
r
s
t
v
x
+
Enumerator
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
y
+
Related Functions
c
d
g
m
o
p
t
w
x
+
Files
File List
+
File Members
+
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
z
+
Typedefs
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Enumerations
c
d
f
i
j
s
t
x
+
Enumerator
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
w
x
+
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Examples
bits_math_unittest.cpp
Go to the documentation of this file.
1
/* +------------------------------------------------------------------------+
2
| Mobile Robot Programming Toolkit (MRPT) |
3
| http://www.mrpt.org/ |
4
| |
5
| Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6
| See: http://www.mrpt.org/Authors - All rights reserved. |
7
| Released under BSD License. See details in http://www.mrpt.org/License |
8
+------------------------------------------------------------------------+ */
9
10
#include <
mrpt/core/bits_math.h
>
11
#include <gtest/gtest.h>
12
13
TEST
(bits_math,
sign
)
14
{
15
16
EXPECT_EQ(
mrpt::sign
(-8), -1);
17
EXPECT_EQ(
mrpt::sign
(8), 1);
18
EXPECT_EQ(
mrpt::sign
(0), 1);
19
EXPECT_EQ(
mrpt::sign
(8.0), 1);
20
EXPECT_EQ(
mrpt::sign
(-8.0), -1);
21
EXPECT_EQ(
mrpt::sign
(0.0), 1);
22
}
23
24
TEST
(bits_math,
keep_min
)
25
{
26
int
min
= 40;
27
mrpt::keep_min
(
min
, 30);
28
EXPECT_EQ(
min
, 30);
29
mrpt::keep_min
(
min
, 80);
30
EXPECT_EQ(
min
, 30);
31
mrpt::keep_min
(
min
, -80);
32
EXPECT_EQ(
min
, -80);
33
}
34
35
TEST
(bits_math,
round2up
)
36
{
37
EXPECT_EQ(
mrpt::round2up
(4), 4);
38
EXPECT_EQ(
mrpt::round2up
(5), 8);
39
EXPECT_EQ(
mrpt::round2up
(200), 256);
40
}
min
#define min(a, b)
Definition:
rplidar_driver.cpp:42
mrpt::keep_min
void keep_min(T &var, const K test_val)
If the second argument is below the first one, set the first argument to this lower value...
Definition:
core/include/mrpt/core/bits_math.h:124
bits_math.h
TEST
TEST(bits_math, sign)
Definition:
bits_math_unittest.cpp:13
mrpt::round2up
T round2up(T val)
Round up to the nearest power of two of a given number.
Definition:
core/include/mrpt/core/bits_math.h:156
mrpt::sign
int sign(T x)
Returns the sign of X as "1" or "-1".
Definition:
core/include/mrpt/core/bits_math.h:68
Page generated by
Doxygen 1.8.14
for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020