documentation(round): Added copyright-header and comments for the rounding-functions.
This commit is contained in:
parent
f77dd2b23a
commit
4244cf107b
|
@ -1,13 +1,33 @@
|
||||||
|
// ufn_round.h: More feature-rich rounding functions.
|
||||||
|
// Under MIT-License. Copyright by Eric-Paul Ickhorn (epickh).
|
||||||
|
|
||||||
#ifndef UFN_ROUND_H
|
#ifndef UFN_ROUND_H
|
||||||
#define UFN_ROUND_H
|
#define UFN_ROUND_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/// @brief Rounds a value down to the last multiple of a stepping.
|
||||||
|
/// @param value Value to round down (floor).
|
||||||
|
/// @param stepping Stepping to round the value to.
|
||||||
|
/// @return Rounded value
|
||||||
int64_t ufn_floor_i64(int64_t value, int64_t stepping);
|
int64_t ufn_floor_i64(int64_t value, int64_t stepping);
|
||||||
|
|
||||||
|
/// @brief Rounds a value up to the next multiple of a stepping.
|
||||||
|
/// @param value Value to round up (ceil).
|
||||||
|
/// @param stepping Stepping to round the value to.
|
||||||
|
/// @return Rounded value
|
||||||
int64_t ufn_ceil_i64(int64_t value, int64_t stepping);
|
int64_t ufn_ceil_i64(int64_t value, int64_t stepping);
|
||||||
|
|
||||||
|
/// @brief Rounds down (Floors) a value to the last power of 2.
|
||||||
|
/// @param value Value to find the nearest lower power of 2 of.
|
||||||
|
/// @return Power of 2 which is nearest lower one to 'value'.
|
||||||
uint64_t ufn_floor_pow2(uint64_t value);
|
uint64_t ufn_floor_pow2(uint64_t value);
|
||||||
|
|
||||||
|
/// @brief Rounds up (Ceils) a value to the next power of 2.
|
||||||
|
/// @note Internally, this uses the 'ufn_floor_pow2'-function but multiplies
|
||||||
|
/// its result by two to get the next higher power.
|
||||||
|
/// @param value Value to round up to the next power of 2.
|
||||||
|
/// @return Power of 2 which is the nearest higher one from 'value'/
|
||||||
uint64_t ufn_ceil_pow2(uint64_t value);
|
uint64_t ufn_ceil_pow2(uint64_t value);
|
||||||
|
|
||||||
#ifdef UFN_IMPLEMENTATION
|
#ifdef UFN_IMPLEMENTATION
|
||||||
|
|
Loading…
Reference in New Issue