File indexing completed on 2026-09-22 08:59:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef _Standard_Real_HeaderFile
0016 #define _Standard_Real_HeaderFile
0017
0018 #include <algorithm>
0019 #include <cmath>
0020 #include <climits>
0021 #include <float.h>
0022
0023 #ifdef _MSC_VER
0024 #ifndef _USE_MATH_DEFINES
0025 #define _USE_MATH_DEFINES
0026 #endif
0027 #include <math.h>
0028 #endif
0029
0030 #include <Standard_TypeDef.hxx>
0031
0032
0033 Standard_DEPRECATED("This function duplicates std::acos and will be removed in future releases. "
0034 "Use std::acos instead.")
0035 inline double ACos(const double theValue)
0036 {
0037 return std::acos(theValue);
0038 }
0039
0040
0041
0042
0043 Standard_DEPRECATED("Deprecated, use std::acos instead")
0044 Standard_EXPORT double ACosApprox(const double theValue);
0045
0046
0047 Standard_DEPRECATED("This function duplicates std::asin and will be removed in future releases. "
0048 "Use std::asin instead.")
0049 inline double ASin(const double theValue)
0050 {
0051 return std::asin(theValue);
0052 }
0053
0054
0055
0056 Standard_DEPRECATED("This function duplicates std::atan2 and will be removed in future releases. "
0057 "Use std::atan2 instead.")
0058 inline double ATan2(const double theX, const double theY)
0059 {
0060 return std::atan2(theX, theY);
0061 }
0062
0063
0064 Standard_DEPRECATED("This function duplicates std::atanh and will be removed in future releases. "
0065 "Use std::atanh instead.")
0066 inline double ATanh(const double theValue)
0067 {
0068 return std::atanh(theValue);
0069 }
0070
0071
0072 Standard_DEPRECATED("This function duplicates std::acosh and will be removed in future releases. "
0073 "Use std::acosh instead.")
0074 inline double ACosh(const double theValue)
0075 {
0076 return std::acosh(theValue);
0077 }
0078
0079
0080 Standard_DEPRECATED("This function duplicates std::cosh and will be removed in future releases. "
0081 "Use std::cosh instead.")
0082 inline double Cosh(const double theValue)
0083 {
0084 return std::cosh(theValue);
0085 }
0086
0087
0088 Standard_DEPRECATED("This function duplicates std::sinh and will be removed in future releases. "
0089 "Use std::sinh instead.")
0090 inline double Sinh(const double theValue)
0091 {
0092 return std::sinh(theValue);
0093 }
0094
0095
0096 Standard_DEPRECATED("This function duplicates std::log and will be removed in future releases. "
0097 "Use std::log instead.")
0098 inline double Log(const double theValue)
0099 {
0100 return std::log(theValue);
0101 }
0102
0103
0104 Standard_DEPRECATED("This function duplicates std::sqrt and will be removed in future releases. "
0105 "Use std::sqrt instead.")
0106 inline double Sqrt(const double theValue)
0107 {
0108 return std::sqrt(theValue);
0109 }
0110
0111
0112
0113 Standard_DEPRECATED(
0114 "This function duplicates std::nextafter and will be removed in future releases. "
0115 "Use std::nextafter instead.")
0116 inline double NextAfter(const double theValue, const double theDirection)
0117 {
0118 return std::nextafter(theValue, theDirection);
0119 }
0120
0121
0122
0123 Standard_DEPRECATED(
0124 "This function duplicates std::copysign and will be removed in future releases. "
0125 "Use std::copysign instead.")
0126 inline double Sign(const double theMagnitude, const double theSign)
0127 {
0128 return std::copysign(theMagnitude, theSign);
0129 }
0130
0131
0132 [[nodiscard]] constexpr double RealSmall()
0133 {
0134 return DBL_MIN;
0135 }
0136
0137
0138
0139 Standard_DEPRECATED("This function duplicates std::abs and will be removed in future releases. "
0140 "Use std::abs instead.")
0141 inline double Abs(const double theValue)
0142 {
0143 return std::abs(theValue);
0144 }
0145
0146
0147
0148 [[nodiscard]] inline bool IsEqual(const double theValue1, const double theValue2)
0149 {
0150 return std::abs(theValue1 - theValue2) < RealSmall();
0151 }
0152
0153
0154 [[nodiscard]] constexpr int RealDigits()
0155 {
0156 return DBL_DIG;
0157 }
0158
0159
0160
0161 [[nodiscard]] constexpr double RealEpsilon()
0162 {
0163 return DBL_EPSILON;
0164 }
0165
0166
0167 [[nodiscard]] constexpr double RealFirst()
0168 {
0169 return -DBL_MAX;
0170 }
0171
0172
0173 [[nodiscard]] constexpr int RealFirst10Exp()
0174 {
0175 return DBL_MIN_10_EXP;
0176 }
0177
0178
0179 [[nodiscard]] constexpr double RealLast()
0180 {
0181 return DBL_MAX;
0182 }
0183
0184
0185 [[nodiscard]] constexpr int RealLast10Exp()
0186 {
0187 return DBL_MAX_10_EXP;
0188 }
0189
0190
0191 [[nodiscard]] constexpr int RealMantissa()
0192 {
0193 return DBL_MANT_DIG;
0194 }
0195
0196
0197 [[nodiscard]] constexpr int RealRadix()
0198 {
0199 return FLT_RADIX;
0200 }
0201
0202
0203 [[nodiscard]] constexpr int RealSize()
0204 {
0205 return CHAR_BIT * sizeof(double);
0206 }
0207
0208
0209 [[nodiscard]] constexpr double IntToReal(const int theValue)
0210 {
0211 return theValue;
0212 }
0213
0214
0215 Standard_DEPRECATED("This function duplicates std::atan and will be removed in future releases. "
0216 "Use std::atan instead.")
0217 inline double ATan(const double theValue)
0218 {
0219 return std::atan(theValue);
0220 }
0221
0222
0223 Standard_DEPRECATED("This function duplicates std::ceil and will be removed in future releases. "
0224 "Use std::ceil instead.")
0225 inline double Ceiling(const double theValue)
0226 {
0227 return std::ceil(theValue);
0228 }
0229
0230
0231
0232 Standard_DEPRECATED("This function duplicates std::cos and will be removed in future releases. "
0233 "Use std::cos instead.")
0234 inline double Cos(const double theValue)
0235 {
0236 return std::cos(theValue);
0237 }
0238
0239
0240
0241
0242 [[nodiscard]] inline double Epsilon(const double theValue)
0243 {
0244 return theValue >= 0.0 ? (std::nextafter(theValue, RealLast()) - theValue)
0245 : (theValue - std::nextafter(theValue, RealFirst()));
0246 }
0247
0248
0249
0250 Standard_DEPRECATED("This function duplicates std::exp and will be removed in future releases. "
0251 "Use std::exp instead.")
0252 inline double Exp(const double theValue)
0253 {
0254 return std::exp(theValue);
0255 }
0256
0257
0258
0259 Standard_DEPRECATED("This function duplicates std::floor and will be removed in future releases. "
0260 "Use std::floor instead.")
0261 inline double Floor(const double theValue)
0262 {
0263 return std::floor(theValue);
0264 }
0265
0266
0267
0268 Standard_DEPRECATED("This function duplicates std::trunc and will be removed in future releases. "
0269 "Use std::trunc instead.")
0270 inline double IntegerPart(const double theValue)
0271 {
0272 return std::trunc(theValue);
0273 }
0274
0275
0276
0277 Standard_DEPRECATED("This function duplicates std::log10 and will be removed in future releases. "
0278 "Use std::log10 instead.")
0279 inline double Log10(const double theValue)
0280 {
0281 return std::log10(theValue);
0282 }
0283
0284
0285
0286 Standard_DEPRECATED("This function duplicates std::max and will be removed in future releases. "
0287 "Use std::max instead.")
0288 constexpr double Max(const double theValue1, const double theValue2)
0289 {
0290 return (std::max)(theValue1, theValue2);
0291 }
0292
0293
0294
0295 Standard_DEPRECATED("This function duplicates std::min and will be removed in future releases. "
0296 "Use std::min instead.")
0297 constexpr double Min(const double theValue1, const double theValue2)
0298 {
0299 return (std::min)(theValue1, theValue2);
0300 }
0301
0302
0303 Standard_DEPRECATED("This function duplicates std::pow and will be removed in future releases. "
0304 "Use std::pow instead.")
0305 inline double Pow(const double theValue, const double thePower)
0306 {
0307 return std::pow(theValue, thePower);
0308 }
0309
0310
0311
0312 [[nodiscard]] inline double RealPart(const double theValue)
0313 {
0314 return std::abs(std::trunc(theValue) - theValue);
0315 }
0316
0317
0318
0319 [[nodiscard]] constexpr int RealToInt(const double theValue)
0320 {
0321
0322
0323
0324 return theValue < static_cast<double>(INT_MIN)
0325 ? static_cast<int>(INT_MIN)
0326 : (theValue > static_cast<double>(INT_MAX) ? static_cast<int>(INT_MAX)
0327 : static_cast<int>(theValue));
0328 }
0329
0330
0331
0332
0333 [[nodiscard]] constexpr float RealToShortReal(const double theValue)
0334 {
0335 return theValue < -FLT_MAX ? -FLT_MAX
0336 : theValue > FLT_MAX ? FLT_MAX
0337 : static_cast<float>(theValue);
0338 }
0339
0340
0341
0342 Standard_DEPRECATED("This function duplicates std::round and will be removed in future releases. "
0343 "Use std::round instead.")
0344 inline double Round(const double theValue)
0345 {
0346 return std::round(theValue);
0347 }
0348
0349
0350
0351 Standard_DEPRECATED("This function duplicates std::sin and will be removed in future releases. "
0352 "Use std::sin instead.")
0353 inline double Sin(const double theValue)
0354 {
0355 return std::sin(theValue);
0356 }
0357
0358
0359
0360 Standard_DEPRECATED("This function duplicates std::asinh and will be removed in future releases. "
0361 "Use std::asinh instead.")
0362 inline double ASinh(const double theValue)
0363 {
0364 return std::asinh(theValue);
0365 }
0366
0367
0368 [[nodiscard]] constexpr double Square(const double theValue)
0369 {
0370 return theValue * theValue;
0371 }
0372
0373
0374
0375 Standard_DEPRECATED("This function duplicates std::tan and will be removed in future releases. "
0376 "Use std::tan instead.")
0377 inline double Tan(const double theValue)
0378 {
0379 return std::tan(theValue);
0380 }
0381
0382
0383
0384 Standard_DEPRECATED("This function duplicates std::tanh and will be removed in future releases. "
0385 "Use std::tanh instead.")
0386 inline double Tanh(const double theValue)
0387 {
0388 return std::tanh(theValue);
0389 }
0390
0391 #endif