Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Testing: https://ideone.com/u0IkCn
- define float LogError = 0.00000005f;
- public static float Log(float value)
- {
- float nom = (value - 1.0f) / (value + 1.0f);
- float dnm = 1.0f;
- float p = nom * nom;
- float a = nom;
- float log = a;
- while (true) {
- nom = nom * p;
- dnm = dnm + 2.0f;
- float an = nom / dnm;
- log = log + an;
- float delta = an - a;
- if (delta < 0) delta = -delta;
- if (delta <= LogError)
- break;
- a = an;
- }
- return 2.0f * log;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement