Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Done Add log2 to @EVAL

May
13,008
174
log2(x) = log(x)/log(2) = log10(x)/log10(2)

(if it's not available on its own)
 
FWIW, this works quite well, comparing perfectly vs. Mathematica with the likes of "log2.exe 81e-101 2000" and "log2.exe 81e-101 2000".
Code:
#include <windows.h>
#include <stdio.h>
#include "..\m_apm.h"

// Syntax: LOG2 x d(ecimal precision)
INT main ( INT argc, LPSTR *argv )
{
   if ( argc != 3 ) return 0;
   INT dp = atoi(argv[2]); // decimal places
   MAPM m_x(argv[1]);
   MAPM m_Two(2);
   MAPM m_log2ofx = (m_x.log(dp+3) / m_Two.log(dp+3)).round(dp+2);
   CHAR *szResult = (CHAR*) malloc(m_log2ofx.significant_digits() + dp + 3);
   m_log2ofx.toFixPtString(szResult, dp);
   printf("%s\n", szResult);
   free(szResult);
   return 0;
}
 

Similar threads

Back
Top