Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
2cfe9ee1
Commit
2cfe9ee1
authored
11 years ago
by
Lorenz Meier
Browse files
Options
Downloads
Patches
Plain Diff
Improved limits handling
parent
05d68154
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/modules/mathlib/math/Limits.cpp
+16
-0
16 additions, 0 deletions
src/modules/mathlib/math/Limits.cpp
src/modules/mathlib/math/Limits.hpp
+7
-0
7 additions, 0 deletions
src/modules/mathlib/math/Limits.hpp
with
23 additions
and
0 deletions
src/modules/mathlib/math/Limits.cpp
+
16
−
0
View file @
2cfe9ee1
...
...
@@ -39,6 +39,7 @@
#include
<math.h>
#include
<stdint.h>
#include
"Limits.hpp"
...
...
@@ -61,6 +62,11 @@ unsigned __EXPORT min(unsigned val1, unsigned val2)
return
(
val1
<
val2
)
?
val1
:
val2
;
}
uint64_t
__EXPORT
min
(
uint64_t
val1
,
uint64_t
val2
)
{
return
(
val1
<
val2
)
?
val1
:
val2
;
}
double
__EXPORT
min
(
double
val1
,
double
val2
)
{
return
(
val1
<
val2
)
?
val1
:
val2
;
...
...
@@ -81,6 +87,11 @@ unsigned __EXPORT max(unsigned val1, unsigned val2)
return
(
val1
>
val2
)
?
val1
:
val2
;
}
uint64_t
__EXPORT
max
(
uint64_t
val1
,
uint64_t
val2
)
{
return
(
val1
>
val2
)
?
val1
:
val2
;
}
double
__EXPORT
max
(
double
val1
,
double
val2
)
{
return
(
val1
>
val2
)
?
val1
:
val2
;
...
...
@@ -102,6 +113,11 @@ unsigned __EXPORT constrain(unsigned val, unsigned min, unsigned max)
return
(
val
<
min
)
?
min
:
((
val
>
max
)
?
max
:
val
);
}
uint64_t
__EXPORT
constrain
(
uint64_t
val
,
uint64_t
min
,
uint64_t
max
)
{
return
(
val
<
min
)
?
min
:
((
val
>
max
)
?
max
:
val
);
}
double
__EXPORT
constrain
(
double
val
,
double
min
,
double
max
)
{
return
(
val
<
min
)
?
min
:
((
val
>
max
)
?
max
:
val
);
...
...
This diff is collapsed.
Click to expand it.
src/modules/mathlib/math/Limits.hpp
+
7
−
0
View file @
2cfe9ee1
...
...
@@ -40,6 +40,7 @@
#pragma once
#include
<nuttx/config.h>
#include
<stdint.h>
namespace
math
{
...
...
@@ -50,6 +51,8 @@ int __EXPORT min(int val1, int val2);
unsigned
__EXPORT
min
(
unsigned
val1
,
unsigned
val2
);
uint64_t
__EXPORT
min
(
uint64_t
val1
,
uint64_t
val2
);
double
__EXPORT
min
(
double
val1
,
double
val2
);
float
__EXPORT
max
(
float
val1
,
float
val2
);
...
...
@@ -58,6 +61,8 @@ int __EXPORT max(int val1, int val2);
unsigned
__EXPORT
max
(
unsigned
val1
,
unsigned
val2
);
uint64_t
__EXPORT
max
(
uint64_t
val1
,
uint64_t
val2
);
double
__EXPORT
max
(
double
val1
,
double
val2
);
...
...
@@ -67,6 +72,8 @@ int __EXPORT constrain(int val, int min, int max);
unsigned
__EXPORT
constrain
(
unsigned
val
,
unsigned
min
,
unsigned
max
);
uint64_t
__EXPORT
constrain
(
uint64_t
val
,
uint64_t
min
,
uint64_t
max
);
double
__EXPORT
constrain
(
double
val
,
double
min
,
double
max
);
float
__EXPORT
radians
(
float
degrees
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment