{---------------------------------------------------------------------------}
function exp(x: extended): extended; assembler; {&Frame-} {&Uses none}
{-Accurate exp, result good to extended precision}
asm
{This version of Norbert Juffa's exp is from the VirtualPascal
RTL source,}
{discussed and explained in the VP Bugtracker system. Quote: }
{ }
{ ... "since the 387, F2XM1 can accecpt arguments in [-1, 1]. }
{ }
{ So, we can split the argument into an integer and a fraction part using }
{ FRNDINT and the fraction part will always be -1 <= f <= 1 no matter what}
{ rounding control. This means we don't have to load/restore the FPU }
{ control word (CW) which is slow on modern OOO FPUs (since FLDCW is a }
{ serializing instruction). }
{ }
{ Note that precision is lost in doing exponentation when the fraction is }
{ subtracted from the integer part of the argument. The "naive" code can }
{ loose up to 11 (or 15) bits of the extended precision format for large }
{
DP or EP arguments, yielding a result good to double precision. To get a}
{ function accurate to full extended precision, we need to simulate higher}
{ precision intermediate arithmetic." }
{ Ref: [Virtual Pascal 0000056]: More accurate Exp() function.
URL (Oct.2009):}
{ https://admin.topica.com/lists/virtualpascal@topica.com/read/message.html?sort=a&mid=908867704&start=7}