version 5.4.0
remove CORS default header from PIHTTPServer fix several docs fix PIMathVector::dot return type add units directory with PIUnits facility
This commit is contained in:
95
libs/main/units/piunits_prefix.h
Normal file
95
libs/main/units/piunits_prefix.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/*! \file piunits_prefix.h
|
||||
* \ingroup Core
|
||||
* \~\brief
|
||||
* \~english Unit prefixes
|
||||
* \~russian Префиксы единиц измерения
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
Unit prefix
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PIUNITS_PREFIX_H
|
||||
#define PIUNITS_PREFIX_H
|
||||
|
||||
#include "pistring.h"
|
||||
|
||||
namespace PIUnits {
|
||||
|
||||
class PIP_EXPORT Prefix {
|
||||
friend class Value;
|
||||
|
||||
public:
|
||||
enum {
|
||||
None,
|
||||
|
||||
Deca = 0x100, // da 10^1 10
|
||||
Hecto, // h 10^2 100
|
||||
Kilo, // k 10^3 1000
|
||||
Mega, // M 10^6 1000000
|
||||
Giga, // G 10^9 1000000000
|
||||
Tera, // T 10^12 1000000000000
|
||||
Peta, // P 10^15 1000000000000000
|
||||
Exa, // E 10^18 1000000000000000000
|
||||
Zetta, // Z 10^21 1000000000000000000000
|
||||
Yotta, // Y 10^24 1000000000000000000000000
|
||||
Ronna, // R 10^27 1000000000000000000000000000
|
||||
Quetta, // Q 10^30 1000000000000000000000000000000
|
||||
|
||||
Deci = 0x200, // d 10^−1 0.1
|
||||
Centi, // c 10^−2 0.01
|
||||
Milli, // m 10^−3 0.001
|
||||
Micro, // μ 10^−6 0.000001
|
||||
Nano, // n 10^−9 0.000000001
|
||||
Pico, // p 10^−12 0.000000000001
|
||||
Femto, // f 10^−15 0.000000000000001
|
||||
Atto, // a 10^−18 0.000000000000000001
|
||||
Zepto, // z 10^−21 0.000000000000000000001
|
||||
Yocto, // y 10^−24 0.000000000000000000000001
|
||||
Ronto, // r 10^−27 0.000000000000000000000000001
|
||||
};
|
||||
|
||||
static PIString name(int prefix);
|
||||
static PIString prefix(int prefix);
|
||||
static double multiplier(int prefix);
|
||||
|
||||
private:
|
||||
Prefix();
|
||||
NO_COPY_CLASS(Prefix);
|
||||
static Prefix & instance();
|
||||
static PIString valueToString(double v, void * type_class, int type, char format = 'g', int prec = 5);
|
||||
|
||||
struct P {
|
||||
PIString name;
|
||||
PIString prefix;
|
||||
int pow;
|
||||
double divider;
|
||||
bool non3;
|
||||
};
|
||||
|
||||
const P getPrefix(int p) const;
|
||||
const P getPrefixForValue(double v, bool use_non3, bool use_greater, bool use_smaller) const;
|
||||
|
||||
PIMap<int, P> prefixes;
|
||||
PIMap<int, P *> prefixes_by_pow;
|
||||
P def_prefix;
|
||||
};
|
||||
|
||||
} // namespace PIUnits
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user