Unix and Linux Discussions Tagged with size |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
8 |
5,202 |
UNIX for Beginners Questions & Answers |
|
|
|
3 |
4,175 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
3,132 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
2,103 |
UNIX for Beginners Questions & Answers |
|
|
|
1 |
2,553 |
UNIX for Beginners Questions & Answers |
|
|
|
2 |
4,543 |
UNIX for Advanced & Expert Users |
|
|
|
2 |
14,137 |
AIX |
|
|
|
9 |
6,109 |
Shell Programming and Scripting |
|
|
|
1 |
4,001 |
Solaris |
|
|
|
4 |
4,306 |
AIX |
|
|
|
4 |
2,357 |
Programming |
|
|
|
7 |
3,723 |
Shell Programming and Scripting |
|
|
|
21 |
53,058 |
AIX |
|
|
|
3 |
2,557 |
Shell Programming and Scripting |
|
|
|
7 |
3,625 |
Shell Programming and Scripting |
|
|
|
6 |
9,219 |
Shell Programming and Scripting |
|
|
|
5 |
7,819 |
Shell Programming and Scripting |
|
|
|
8 |
7,103 |
UNIX for Dummies Questions & Answers |
|
|
|
9 |
4,087 |
Programming |
|
|
|
0 |
3,939 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
19,738 |
Solaris |
|
|
|
1 |
8,988 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
11,730 |
Shell Programming and Scripting |
|
|
|
7 |
18,807 |
AIX |
|
|
|
2 |
3,538 |
Shell Programming and Scripting |
|
|
|
4 |
7,154 |
SuSE |
|
|
|
0 |
2,029 |
Solaris BigAdmin RSS |
|
|
|
1 |
5,819 |
Windows & DOS: Issues & Discussions |
|
|
|
2 |
3,020 |
Solaris |
|
|
|
2 |
6,069 |
Solaris |
|
|
|
0 |
4,646 |
Solaris BigAdmin RSS |
|
|
|
2 |
5,175 |
AIX |
|
|
|
6 |
17,577 |
UNIX for Dummies Questions & Answers |
|
|
|
5 |
6,456 |
AIX |
|
|
|
4 |
11,115 |
Solaris |
|
|
|
1 |
2,832 |
Solaris |
|
|
|
0 |
3,097 |
OS X Support RSS |
|
|
|
5 |
23,354 |
UNIX for Advanced & Expert Users |
|
|
|
2 |
25,493 |
AIX |
|
|
|
4 |
6,650 |
UNIX for Dummies Questions & Answers |
ROUNDUP(9) BSD Kernel Developer's Manual ROUNDUP(9)
NAME
roundup -- macros for counting and rounding
SYNOPSIS
#include <sys/param.h>
size
howmany(x, size);
size
roundup(x, size);
size
rounddown(x, size);
size
roundup2(x, size);
int
powerof2(x);
DESCRIPTION
The roundup() and rounddown() macros return an integer from rounding x up and down, respectively, to the next size. The howmany() macro in
turn reveals how many times size fits into x, rounding the residual up.
The roundup2() macro also rounds up, but with the assumption that size is a power of two. If x is indeed a power of two, powerof2() return
1.
RETURN VALUES
The return value is an integer from the respective operation. If x is 0, all macros except powerof2() return 0. The behavior is undefined
if size is 0.
EXAMPLES
The following example rounds the variable rx to a 32-bit boundary:
uint16_t rx;
...
rx = roundup2(rx, sizeof(uint32_t));
SEE ALSO
ilog2(3), param(3), imax(9)
CAVEATS
All described macros make no assumptions about the type of the parameters. These are implicitly assumed to be unsigned integers.
BSD
June 1, 2011 BSD