mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-07-01 18:39:16 +00:00
feat(kernel): update stl headers
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
79
Kernel/include_std/ratio
Normal file
79
Kernel/include_std/ratio
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
This file is part of Fennix Kernel.
|
||||
|
||||
Fennix Kernel is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix Kernel is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <types.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <intmax_t Num, intmax_t Denom = 1>
|
||||
class ratio
|
||||
{
|
||||
public:
|
||||
typedef ratio<Num, Denom> type;
|
||||
static constexpr intmax_t num = Num;
|
||||
static constexpr intmax_t denom = Denom;
|
||||
};
|
||||
|
||||
template <class R1, class R2>
|
||||
using ratio_add = ratio<R1::num * R2::denom + R2::num * R1::denom, R1::denom * R2::denom>;
|
||||
template <class R1, class R2>
|
||||
using ratio_subtract = ratio<R1::num * R2::denom - R2::num * R1::denom, R1::denom * R2::denom>;
|
||||
template <class R1, class R2>
|
||||
using ratio_multiply = ratio<R1::num * R2::num, R1::denom * R2::denom>;
|
||||
template <class R1, class R2>
|
||||
using ratio_divide = ratio<R1::num * R2::denom, R1::denom * R2::num>;
|
||||
|
||||
template <class R1, class R2>
|
||||
struct ratio_equal;
|
||||
template <class R1, class R2>
|
||||
struct ratio_not_equal;
|
||||
template <class R1, class R2>
|
||||
struct ratio_less;
|
||||
template <class R1, class R2>
|
||||
struct ratio_less_equal;
|
||||
template <class R1, class R2>
|
||||
struct ratio_greater;
|
||||
template <class R1, class R2>
|
||||
struct ratio_greater_equal;
|
||||
|
||||
// typedef ratio<1, 1000000000000000000000000000000> quecto;
|
||||
// typedef ratio<1, 1000000000000000000000000000> ronto;
|
||||
// typedef ratio<1, 1000000000000000000000000> yocto;
|
||||
// typedef ratio<1, 1000000000000000000000> zepto;
|
||||
typedef ratio<1, 1000000000000000000> atto;
|
||||
typedef ratio<1, 1000000000000000> femto;
|
||||
typedef ratio<1, 1000000000000> pico;
|
||||
typedef ratio<1, 1000000000> nano;
|
||||
typedef ratio<1, 1000000> micro;
|
||||
typedef ratio<1, 1000> milli;
|
||||
typedef ratio<1, 100> centi;
|
||||
typedef ratio<1, 10> deci;
|
||||
typedef ratio<10, 1> deca;
|
||||
typedef ratio<100, 1> hecto;
|
||||
typedef ratio<1000, 1> kilo;
|
||||
typedef ratio<1000000, 1> mega;
|
||||
typedef ratio<1000000000, 1> giga;
|
||||
typedef ratio<1000000000000, 1> tera;
|
||||
typedef ratio<1000000000000000, 1> peta;
|
||||
typedef ratio<1000000000000000000, 1> exa;
|
||||
// typedef ratio<1000000000000000000000, 1> zetta;
|
||||
// typedef ratio<1000000000000000000000000, 1> yotta;
|
||||
// typedef ratio<1000000000000000000000000000, 1> ronna;
|
||||
// typedef ratio<1000000000000000000000000000000, 1> quetta;
|
||||
}
|
Reference in New Issue
Block a user