2014-12-19 12:14:36 +00:00
|
|
|
/********************************************************************************
|
|
|
|
|
* *
|
|
|
|
|
* This file is part of IfcOpenShell. *
|
|
|
|
|
* *
|
|
|
|
|
* IfcOpenShell is free software: you can redistribute it and/or modify *
|
|
|
|
|
* it under the terms of the Lesser GNU General Public License as published by *
|
|
|
|
|
* the Free Software Foundation, either version 3.0 of the License, or *
|
|
|
|
|
* (at your option) any later version. *
|
|
|
|
|
* *
|
|
|
|
|
* IfcOpenShell 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 *
|
|
|
|
|
* Lesser GNU General Public License for more details. *
|
|
|
|
|
* *
|
|
|
|
|
* You should have received a copy of the Lesser GNU General Public License *
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
|
|
|
* *
|
|
|
|
|
********************************************************************************/
|
2017-12-20 16:38:55 +01:00
|
|
|
|
2026-03-31 15:32:36 +02:00
|
|
|
#include "si_prefix.h"
|
2017-12-20 16:38:55 +01:00
|
|
|
|
2026-03-31 15:32:36 +02:00
|
|
|
double ifcopenshell::si_prefix_to_value(const std::string& prefix) {
|
2023-11-06 20:29:00 +01:00
|
|
|
if (prefix == "EXA") {
|
2023-09-17 12:30:17 +02:00
|
|
|
return 1.e18;
|
2023-10-24 12:21:32 +02:00
|
|
|
}
|
2023-11-06 20:29:00 +01:00
|
|
|
if (prefix == "PETA") {
|
2023-09-17 12:30:17 +02:00
|
|
|
return 1.e15;
|
2023-10-24 12:21:32 +02:00
|
|
|
}
|
2023-11-06 20:29:00 +01:00
|
|
|
if (prefix == "TERA") {
|
2023-09-17 12:30:17 +02:00
|
|
|
return 1.e12;
|
2023-10-24 12:21:32 +02:00
|
|
|
}
|
2023-11-06 20:29:00 +01:00
|
|
|
if (prefix == "GIGA") {
|
2023-09-17 12:30:17 +02:00
|
|
|
return 1.e9;
|
2023-10-24 12:21:32 +02:00
|
|
|
}
|
2023-11-06 20:29:00 +01:00
|
|
|
if (prefix == "MEGA") {
|
2023-09-17 12:30:17 +02:00
|
|
|
return 1.e6;
|
2023-10-24 12:21:32 +02:00
|
|
|
}
|
2023-11-06 20:29:00 +01:00
|
|
|
if (prefix == "KILO") {
|
2023-09-17 12:30:17 +02:00
|
|
|
return 1.e3;
|
2023-10-24 12:21:32 +02:00
|
|
|
}
|
2023-11-06 20:29:00 +01:00
|
|
|
if (prefix == "HECTO") {
|
2023-09-17 12:30:17 +02:00
|
|
|
return 1.e2;
|
2023-10-24 12:21:32 +02:00
|
|
|
}
|
2023-11-06 20:29:00 +01:00
|
|
|
if (prefix == "DECA") {
|
2023-09-17 12:30:17 +02:00
|
|
|
return 1.e1;
|
2023-10-24 12:21:32 +02:00
|
|
|
}
|
2023-11-06 20:29:00 +01:00
|
|
|
if (prefix == "DECI") {
|
2023-09-17 12:30:17 +02:00
|
|
|
return 1.e-1;
|
2023-10-24 12:21:32 +02:00
|
|
|
}
|
2023-11-06 20:29:00 +01:00
|
|
|
if (prefix == "CENTI") {
|
2023-09-17 12:30:17 +02:00
|
|
|
return 1.e-2;
|
2023-10-24 12:21:32 +02:00
|
|
|
}
|
2023-11-06 20:29:00 +01:00
|
|
|
if (prefix == "MILLI") {
|
2023-09-17 12:30:17 +02:00
|
|
|
return 1.e-3;
|
2023-10-24 12:21:32 +02:00
|
|
|
}
|
2023-11-06 20:29:00 +01:00
|
|
|
if (prefix == "MICRO") {
|
2023-09-17 12:30:17 +02:00
|
|
|
return 1.e-6;
|
2023-10-24 12:21:32 +02:00
|
|
|
}
|
2023-11-06 20:29:00 +01:00
|
|
|
if (prefix == "NANO") {
|
2023-09-17 12:30:17 +02:00
|
|
|
return 1.e-9;
|
2023-10-24 12:21:32 +02:00
|
|
|
}
|
2023-11-06 20:29:00 +01:00
|
|
|
if (prefix == "PICO") {
|
2023-09-17 12:30:17 +02:00
|
|
|
return 1.e-12;
|
2023-10-24 12:21:32 +02:00
|
|
|
}
|
2023-11-06 20:29:00 +01:00
|
|
|
if (prefix == "FEMTO") {
|
2023-09-17 12:30:17 +02:00
|
|
|
return 1.e-15;
|
2023-10-24 12:21:32 +02:00
|
|
|
}
|
2023-11-06 20:29:00 +01:00
|
|
|
if (prefix == "ATTO") {
|
2023-09-17 12:30:17 +02:00
|
|
|
return 1.e-18;
|
|
|
|
|
}
|
2023-10-24 12:21:32 +02:00
|
|
|
return 1.;
|
2016-05-24 13:50:50 +02:00
|
|
|
}
|