1#ifndef SCIFIR_UNITS_SPECIAL_UNITS_PERCENTAGE_HPP_INCLUDED
2#define SCIFIR_UNITS_SPECIAL_UNITS_PERCENTAGE_HPP_INCLUDED
4#include "../util/is_number.hpp"
5#include "../units/scalar_unit.hpp"
7#include "boost/math/constants/constants.hpp"
149template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
155template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
161template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
167template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
173template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
179template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
185template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
191template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
197template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
203template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
209template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
215template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
221template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
227template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
233template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
239template<typename T, typename = typename enable_if<scifir::is_number<T>::value>::type>
Class that allows to handle percentages and do calculations with it easy. It supports normal percenta...
percentage operator*(const percentage &x) const
Creates a new percentage as the multiplication of two percentages.
percentage operator/(const percentage &x) const
Creates a new percentage as the division of two percentages.
void initialize_from_string(const string &init_percentage)
Internal function. Initializes the member-variables with an initialization string of percentage.
percentage operator+(const percentage &x) const
Creates a new percentage as the addition of two percentages.
float get_factor() const
Returns the factor of the percentage, not his value. It equals is value divided by 100.
percentage()
Default constructor. The value is 0.
percentage & operator=(const percentage &x)
Copy assignment. The value is copied from the percentage x.
percentage & operator--()
Decrements the value by one.
@ PARTS_PER_MILLION
Percentage, with the ppm symbol. Commonly used in chemistry, it represents 1 in 10^6.
@ RATIO
The normal percentage obtained by a direct ratio of some proportion, you don't need to multiply by 10...
@ PARTS_PER_TRILLION
Percentage, with the ppt symbol. Commonly used in chemistry, it represents 1 in 10^12.
@ PERCENTAGE
Normal percentage, with the % symbol.
@ PARTS_PER_QUATRILLION
Percentage, with the ppq symbol. Commonly used in chemistry, it represents 1 in 10^15.
@ PARTS_PER_BILLION
Percentage, with the ppb symbol. Commonly used in chemistry, it represents 1 in 10^9.
void operator+=(const percentage &x)
Sums the value with the value of the percentage x.
string display_ppm() const
Displays the percentage as ppm, with the ppm symbol.
float get_ppm() const
Returns the factor of the percentage in ppm, not his value. It equals is value multiplied by 10,...
string display_percentage(int number_of_decimals=2) const
Displays the percentage as normal percentage, with the % symbol.
void operator*=(const percentage &x)
Multiplies the value with the value of the percentage x.
const float & get_value() const
It returns the value.
percentage operator-(const percentage &x) const
Creates a new percentage as the difference of two percentages.
float value
The value of the percentage, in numbers related to a 100%. A percentage of 30% has a value of 30,...
void operator/=(const percentage &x)
Divides the value with the value of the percentage x.
void operator-=(const percentage &x)
Substracts the value with the value of the percentage x.
percentage & operator++()
Increments the value by one.
Class that allows to create scalar units, which are composed of a value (as a float) and dimensions....
The namespace scifir contains all scifir-units, excepting the string literals, which are outside.
string to_string(const aid &x)
Creates a string representation of aid, it's for aid equivalent to the display() function of aid.
bool is_percentage(const string &init_percentage)
Checks if a string is an initialization string of percentage.
float operator*(T x, const scifir::percentage &y)
Creates a new percentage as the multiplication of the percentage with the numeric type x.
bool operator!=(T x, const scifir::percentage &y)
Returns true if the value of percentage is not equal to the numeric type x.
bool operator<(T x, const scifir::percentage &y)
Returns true if the numeric type x is lower than the value of percentage y.
scifir::percentage operator-(T x, const scifir::percentage &y)
Creates a new percentage as the difference of the percentage with the numeric type x.
bool operator>(T x, const scifir::percentage &y)
Returns true if the numeric type x is greather than the value of percentage y.
bool operator<=(T x, const scifir::percentage &y)
Returns true if the numeric type x is lower or equal than the value of percentage y.
bool operator>=(T x, const scifir::percentage &y)
Returns true if the numeric type x is equal or greather than the value of percentage y.
scifir::percentage operator+(T x, const scifir::percentage &y)
Creates a new percentage as the addition of the percentage with the numeric type x.
float operator/(T x, const scifir::percentage &y)
Creates a new percentage as the division of the percentage with the numeric type x.
ostream & operator<<(ostream &os, const scifir::percentage &x)
Adds the string representation of the percentage x to an output stream os.
void operator+=(string &x, const scifir::percentage &y)
Concatenates the string representation of percentage y to the string x.
istream & operator>>(istream &is, scifir::percentage &x)
Allows that an istream initializes by string a percentage x.
bool operator==(T x, const scifir::percentage &y)
Returns true if the value of percentage is equal to the numeric type x.