MCPcopy Create free account
hub / github.com/EricLengyel/Terathon-Math-Library / Log

Method Log

TSMath.cpp:531–559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

529}
530
531float Terathon::Log(float x)
532{
533 int32 i = reinterpret_cast<int32&>(x);
534 if (i > 0)
535 {
536 int32 e = (i >> 23) - 127;
537 i = (i & 0x007FFFFF) | 0x3F800000;
538 float f = asfloat(i);
539 float y = (f - 1.0F) / (f + 1.0F);
540 float z = y * y;
541
542 float r = 1.0F / 13.0F;
543 r = r * z + 1.0F / 11.0F;
544 r = r * z + 1.0F / 9.0F;
545 r = r * z + 1.0F / 7.0F;
546 r = r * z + 1.0F / 5.0F;
547 r = r * z + 1.0F / 3.0F;
548 r = r * z + 1.0F;
549
550 return (r * (y * 2.0F) + float(e) * Math::ln_2);
551 }
552 else if (x >= 0.0F)
553 {
554 return (Math::minus_infinity);
555 }
556
557 static const uint32 nan = 0x7FFFFFFF;
558 return (asfloat(nan));
559}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected