Time Shield Library
C++ library for working with time
Toggle main menu visibility
Loading...
Searching...
No Matches
floor_math.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: MIT
2
#pragma once
3
#ifndef TIME_SHIELD_HEADER_TIME_SHIELD_DETAIL_FLOOR_MATH_HPP_INCLUDED
4
#define TIME_SHIELD_HEADER_TIME_SHIELD_DETAIL_FLOOR_MATH_HPP_INCLUDED
5
8
9
namespace
time_shield
{
10
namespace
detail
{
11
13
template
<
class
T>
14
TIME_SHIELD_CONSTEXPR
inline
T
floor_div
(T a, T b)
noexcept
{
15
return
static_cast<
T
>
((a / b) - (((a % b) != 0 && a < 0) ? 1 : 0));
16
}
17
19
template
<
class
T>
20
TIME_SHIELD_CONSTEXPR
inline
T
floor_mod
(T a, T b)
noexcept
{
21
return
static_cast<
T
>
((a % b) + (((a % b) < 0) ? b : 0));
22
}
23
24
}
// namespace detail
25
}
// namespace time_shield
26
27
#endif
// TIME_SHIELD_HEADER_TIME_SHIELD_DETAIL_FLOOR_MATH_HPP_INCLUDED
time_shield::detail
Definition
fast_date.hpp:14
time_shield::detail::floor_mod
TIME_SHIELD_CONSTEXPR T floor_mod(T a, T b) noexcept
Floor-mod for positive modulus (returns r in [0..b)).
Definition
floor_math.hpp:20
time_shield::detail::floor_div
TIME_SHIELD_CONSTEXPR T floor_div(T a, T b) noexcept
Floor division for positive divisor.
Definition
floor_math.hpp:14
time_shield
Main namespace for the Time Shield library.
include
time_shield
detail
floor_math.hpp
Generated by
1.17.0