New IO structure, unexpexted error in C code
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using static System.Net.WebRequestMethods;
|
||||
|
||||
namespace StgSharp.Math
|
||||
{
|
||||
public static partial class Calc
|
||||
{
|
||||
|
||||
static private readonly float[] logArray =
|
||||
private static readonly float[] logArray =
|
||||
{
|
||||
0f, 0.00995033085316809f, 0.0198026272961797f, 0.0295588022415444f, 0.0392207131532813f, 0.048790164169432f, 0.0582689081239758f, 0.0676586484738149f, 0.0769610411361284f, 0.0861776962410524f,
|
||||
0.0953101798043249f, 0.104360015324243f, 0.113328685307003f, 0.122217632724249f, 0.131028262406404f, 0.139761942375159f, 0.148420005118273f, 0.157003748809665f, 0.165514438477573f, 0.173953307123438f,
|
||||
@@ -30,9 +26,9 @@ namespace StgSharp.Math
|
||||
/// <returns>
|
||||
/// Returns the value of ln(x).
|
||||
/// </returns>
|
||||
public unsafe static float Log(float x)
|
||||
public static unsafe float Log(float x)
|
||||
{
|
||||
if (x<0)
|
||||
if (x < 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
@@ -45,24 +41,24 @@ namespace StgSharp.Math
|
||||
input >>= 9;
|
||||
input += 0b_0011_1111_1000_0000_0000_0000_0000_0000;
|
||||
float result = *(float*)&input;
|
||||
int order = (int)(result * 100)-100;
|
||||
int order = (int)(result * 100) - 100;
|
||||
|
||||
float cache = (result) / (1f + 0.01f * order) -1 ;
|
||||
float cache = (result) / (1f + 0.01f * order) - 1;
|
||||
result = cache * -0.25f + 0.3333333333333f;
|
||||
result = result * cache - 0.5f;
|
||||
result = result * cache + 1.0f;
|
||||
result *= cache;
|
||||
|
||||
return
|
||||
f*0.6931471806f +
|
||||
result +
|
||||
return
|
||||
f * 0.6931471806f +
|
||||
result +
|
||||
logArray[order];
|
||||
}
|
||||
|
||||
|
||||
public static float Log(float x, float y)
|
||||
{
|
||||
return Log(x)/Log(y);
|
||||
return Log(x) / Log(y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user