2008-12-30 00:23:33 +01:00
|
|
|
#include <math.h>
|
|
|
|
#include "kosSyst.h"
|
|
|
|
extern "C" int _fltused = 0;
|
2011-01-25 13:53:48 +01:00
|
|
|
double __cdecl acos(double x)
|
2008-12-30 00:23:33 +01:00
|
|
|
{
|
|
|
|
__asm {
|
|
|
|
fld qword ptr [esp+4]
|
|
|
|
fld1
|
|
|
|
fadd st, st(1)
|
|
|
|
fld1
|
|
|
|
fsub st, st(2)
|
|
|
|
fmulp st(1), st
|
|
|
|
fsqrt
|
|
|
|
fxch st(1)
|
|
|
|
fpatan
|
|
|
|
}
|
|
|
|
}
|
2011-01-25 13:53:48 +01:00
|
|
|
double __cdecl asin(double x)
|
2008-12-30 00:23:33 +01:00
|
|
|
{
|
|
|
|
__asm {
|
|
|
|
fld qword ptr [esp+4]
|
|
|
|
fld1
|
|
|
|
fadd st, st(1)
|
|
|
|
fld1
|
|
|
|
fsub st, st(2)
|
|
|
|
fmulp st(1), st
|
|
|
|
fsqrt
|
|
|
|
fpatan
|
|
|
|
ret
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if _MSC_VER <= 1200
|
|
|
|
extern "C" double _ftol(double x)
|
|
|
|
{
|
|
|
|
__asm {
|
|
|
|
fld qword ptr [esp+4]
|
|
|
|
push 1F3Fh
|
|
|
|
fstcw word ptr [esp+2]
|
|
|
|
fldcw word ptr [esp]
|
|
|
|
frndint
|
|
|
|
fldcw word ptr [esp+2]
|
|
|
|
add esp, 4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2011-01-25 13:53:48 +01:00
|
|
|
double __cdecl ceil(double x)
|
2008-12-30 00:23:33 +01:00
|
|
|
{
|
|
|
|
__asm {
|
|
|
|
fld qword ptr [esp+4]
|
|
|
|
push 1B3Fh
|
|
|
|
fstcw word ptr [esp+2]
|
|
|
|
fldcw word ptr [esp]
|
|
|
|
frndint
|
|
|
|
fldcw word ptr [esp+2]
|
|
|
|
add esp, 4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-25 13:53:48 +01:00
|
|
|
double __cdecl floor(double x)
|
2008-12-30 00:23:33 +01:00
|
|
|
{
|
|
|
|
__asm {
|
|
|
|
fld qword ptr [esp+4]
|
|
|
|
push 173Fh
|
|
|
|
fstcw word ptr [esp+2]
|
|
|
|
fldcw word ptr [esp]
|
|
|
|
frndint
|
|
|
|
fldcw word ptr [esp+2]
|
|
|
|
add esp, 4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-25 13:53:48 +01:00
|
|
|
double __cdecl round(double x)
|
2008-12-30 00:23:33 +01:00
|
|
|
{
|
|
|
|
__asm {
|
|
|
|
fld qword ptr [esp+4]
|
|
|
|
push 133Fh
|
|
|
|
fstcw word ptr [esp+2]
|
|
|
|
fldcw word ptr [esp]
|
|
|
|
frndint
|
|
|
|
fldcw word ptr [esp+2]
|
|
|
|
add esp, 4
|
|
|
|
}
|
|
|
|
}
|