Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Core Modules
dune-common
Commits
95bb15ad
Commit
95bb15ad
authored
18 years ago
by
Markus Blatt
Browse files
Options
Downloads
Patches
Plain Diff
Added numeric_limits for bigunsignedint together with a little test.
[[Imported from SVN: r4517]]
parent
09a52e32
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
common/bigunsignedint.hh
+93
-0
93 additions, 0 deletions
common/bigunsignedint.hh
common/test/Makefile.am
+6
-1
6 additions, 1 deletion
common/test/Makefile.am
common/test/bigunsignedinttest.cc
+34
-0
34 additions, 0 deletions
common/test/bigunsignedinttest.cc
with
133 additions
and
1 deletion
common/bigunsignedint.hh
+
93
−
0
View file @
95bb15ad
...
...
@@ -12,6 +12,12 @@
* @brief Portable very large unsigned integers
* @author Peter Bastian
*/
namespace
std
{
template
<
class
T
>
struct
numeric_limits
;
}
namespace
Dune
{
/** @addtogroup Common
...
...
@@ -114,6 +120,8 @@ namespace Dune
unsigned
int
touint
()
const
;
friend
class
bigunsignedint
<
k
/
2
>
;
friend
class
std
::
numeric_limits
<
bigunsignedint
<
k
>
>
;
private
:
unsigned
short
digit
[
n
];
#ifdef HAVE_MPI
...
...
@@ -494,4 +502,89 @@ namespace Dune
/** @} */
}
namespace
std
{
template
<
class
T
>
struct
numeric_limits
;
template
<
int
k
>
struct
numeric_limits
<
Dune
::
bigunsignedint
<
k
>
>
{
static
const
bool
is_specialized
=
true
;
static
Dune
::
bigunsignedint
<
k
>
min
()
{
return
static_cast
<
Dune
::
bigunsignedint
<
k
>
>
(
0
);
}
static
Dune
::
bigunsignedint
<
k
>
max
()
{
Dune
::
bigunsignedint
<
k
>
max_
;
for
(
std
::
size_t
i
=
0
;
i
<
Dune
::
bigunsignedint
<
k
>::
n
;
++
i
)
max_
.
digit
[
i
]
=
std
::
numeric_limits
<
unsigned
short
>::
max
();
return
max_
;
}
static
const
int
digits
=
Dune
::
bigunsignedint
<
k
>::
bits
*
Dune
::
bigunsignedint
<
k
>::
n
;
static
const
bool
is_signed
=
false
;
static
const
bool
is_integer
=
true
;
static
const
bool
is_exact
=
true
;
static
const
int
radix
=
2
;
static
Dune
::
bigunsignedint
<
k
>
epsilon
()
{
return
static_cast
<
Dune
::
bigunsignedint
<
k
>
>
(
0
);
}
static
Dune
::
bigunsignedint
<
k
>
round_error
()
{
return
static_cast
<
Dune
::
bigunsignedint
<
k
>
>
(
0
);
}
static
const
int
min_exponent
=
0
;
static
const
int
min_exponent10
=
0
;
static
const
int
max_exponent
=
0
;
static
const
int
max_exponent10
=
0
;
static
const
bool
has_infinity
=
false
;
static
const
bool
has_quiet_NaN
=
false
;
static
const
bool
has_signaling_NaN
=
false
;
static
const
float_denorm_style
has_denorm
=
denorm_absent
;
static
const
bool
has_denorm_loss
=
false
;
static
Dune
::
bigunsignedint
<
k
>
infinity
()
throw
()
{
return
static_cast
<
Dune
::
bigunsignedint
<
k
>
>
(
0
);
}
static
Dune
::
bigunsignedint
<
k
>
quiet_NaN
()
throw
()
{
return
static_cast
<
Dune
::
bigunsignedint
<
k
>
>
(
0
);
}
static
Dune
::
bigunsignedint
<
k
>
signaling_NaN
()
throw
()
{
return
static_cast
<
Dune
::
bigunsignedint
<
k
>
>
(
0
);
}
static
Dune
::
bigunsignedint
<
k
>
denorm_min
()
throw
()
{
return
static_cast
<
Dune
::
bigunsignedint
<
k
>
>
(
0
);
}
static
const
bool
is_iec559
=
false
;
static
const
bool
is_bounded
=
true
;
static
const
bool
is_modulo
=
true
;
static
const
bool
traps
=
__glibcxx_integral_traps
;
static
const
bool
tinyness_before
=
false
;
static
const
float_round_style
round_style
=
round_toward_zero
;
};
}
#endif
This diff is collapsed.
Click to expand it.
common/test/Makefile.am
+
6
−
1
View file @
95bb15ad
...
...
@@ -2,7 +2,8 @@
TESTPROGS
=
parsetest test-stack arraylisttest smartpointertest
\
sllisttest iteratorfacadetest tuplestest fmatrixtest
\
poolallocatortest settest gcdlcdtest streamtest
poolallocatortest settest gcdlcdtest streamtest
\
bigunsignedinttest
# exprtmpl
# which tests to run
...
...
@@ -13,6 +14,10 @@ check_PROGRAMS = $(TESTPROGS)
# define the programs
bigunsignedinttest_SOURCES
=
bigunsignedinttest.cc
bigunsignedinttest_DEPENDENCIES
=
$(
LIBDUNE
)
parsetest_SOURCES
=
parsetest.cc
parsetest_DEPENDENCIES
=
$(
LOCAL_LIBS
)
...
...
This diff is collapsed.
Click to expand it.
common/test/bigunsignedinttest.cc
0 → 100644
+
34
−
0
View file @
95bb15ad
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#include
"config.h"
#include
<dune/common/bigunsignedint.hh>
#include
<limits>
#include
<iostream>
int
main
()
{
std
::
cout
<<
"unsigned short: max="
<<
std
::
numeric_limits
<
unsigned
short
>::
max
()
<<
" min="
<<
std
::
numeric_limits
<
unsigned
short
>::
min
()
<<
" digits="
<<
std
::
numeric_limits
<
unsigned
short
>::
digits
<<
std
::
endl
;
std
::
cout
<<
"int: max="
<<
std
::
numeric_limits
<
int
>::
max
()
<<
" min="
<<
std
::
numeric_limits
<
int
>::
min
()
<<
" digits="
<<
std
::
numeric_limits
<
int
>::
digits
<<
std
::
endl
;
std
::
cout
<<
"unsigned int: max="
<<
std
::
numeric_limits
<
unsigned
int
>::
max
()
<<
" min="
<<
std
::
numeric_limits
<
unsigned
int
>::
min
()
<<
" digits="
<<
std
::
numeric_limits
<
unsigned
int
>::
digits
<<
" digits10="
<<
std
::
numeric_limits
<
unsigned
int
>::
digits10
<<
" radix="
<<
std
::
numeric_limits
<
unsigned
int
>::
radix
<<
" eps="
<<
std
::
numeric_limits
<
unsigned
int
>::
epsilon
()
<<
" round_error="
<<
std
::
numeric_limits
<
unsigned
int
>::
round_error
()
<<
" min_exponent="
<<
std
::
numeric_limits
<
unsigned
int
>::
min_exponent
<<
" float_denorm_style="
<<
std
::
numeric_limits
<
unsigned
int
>::
has_denorm
<<
std
::
endl
;
std
::
cout
<<
"bigunsignedint: max="
<<
std
::
numeric_limits
<
Dune
::
bigunsignedint
<
32
>
>::
max
()
<<
" min="
<<
std
::
numeric_limits
<
Dune
::
bigunsignedint
<
32
>
>::
min
()
<<
" digits="
<<
std
::
numeric_limits
<
Dune
::
bigunsignedint
<
32
>
>::
digits
<<
std
::
endl
;
std
::
cout
<<
"bigunsignedint: max="
<<
std
::
numeric_limits
<
Dune
::
bigunsignedint
<
100
>
>::
max
()
<<
" min="
<<
std
::
numeric_limits
<
Dune
::
bigunsignedint
<
100
>
>::
min
()
<<
" digits="
<<
std
::
numeric_limits
<
Dune
::
bigunsignedint
<
100
>
>::
digits
<<
std
::
endl
;
}
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