Files
Work/common/MATH.CPP
2024-08-07 09:09:36 -04:00

37 lines
880 B
C++

#include <common/math.hpp>
const double Math::mscPI=3.14159265358979323846;
const double Math::msc2PI=3.14159265358979323846*2.00;
const double Math::mscLN10=2.30258509299405E+000;
const double Math::mscOneOverLN10=0.43429448190325E+000;
const double Math::mscPIOver180=1.74532925199433E-002;
const double Math::mscPIUnder180=5.72957795130823E+001;
float Math::power(float powerBase,int exponent)
{
float basePower(1.00);
if(!exponent)return 1.00;
for(int count=0;count<exponent;count++)basePower*=powerBase;
return basePower;
}
int Math::sqrt(int someInt)
{
int oddInt(1);
int oldArg(someInt);
int firstSqrt;
while(0<someInt){someInt-=oddInt;oddInt+=2;}
firstSqrt=oddInt>>1;
if(square(firstSqrt)-firstSqrt+1>oldArg)return firstSqrt+1;
return firstSqrt;
}
long Math::factorial(long nDegree)
{
if(nDegree)return nDegree*factorial(nDegree-1);
else return 1L;
}