mirror of
https://github.com/libretro/ppsspp.git
synced 2024-12-02 22:26:25 +00:00
30 lines
524 B
C++
30 lines
524 B
C++
// Copyright 2013 Dolphin Emulator Project
|
|
// Licensed under GPLv2+
|
|
// Refer to the license.txt file included.
|
|
|
|
#pragma once
|
|
|
|
namespace MathUtil
|
|
{
|
|
|
|
#define ROUND_UP(x, a) (((x) + (a) - 1) & ~((a) - 1))
|
|
#define ROUND_DOWN(x, a) ((x) & ~((a) - 1))
|
|
|
|
template<class T>
|
|
inline void Clamp(T* val, const T& min, const T& max)
|
|
{
|
|
if (*val < min)
|
|
*val = min;
|
|
else if (*val > max)
|
|
*val = max;
|
|
}
|
|
|
|
template<class T>
|
|
inline T Clamp(const T val, const T& min, const T& max)
|
|
{
|
|
T ret = val;
|
|
Clamp(&ret, min, max);
|
|
return ret;
|
|
}
|
|
|
|
} |