logarithms PACKAGE MATH_REAL

C

create

Hello,
there are two functions for logarithms in PACKAGE MATH_REAL:

function LOG (X : real ) return real;
-- returns natural logarithm of X; X > 0

function LOG (BASE: positive; X : real) return real;
-- returns logarithm base BASE of X; X > 0In my project i used
first:constant CONST_LOG_NUMBER_SAMPLES : Natural :=
Natural(ceil(LOG(realCONST_NUMBER_SAMPLES))));
and it is correct.But I can not make second version:constant
CONST_LOG_NUMBER_SAMPLES : Natural :=
Natural(ceil(LOG(2,real(CONST_NUMBER_SAMPLES))));ORconstant
CONST_LOG_NUMBER_SAMPLES : Natural :=
Natural(ceil(LOG(real(2),real(CONST_NUMBER_SAMPLES))));How should I write
LOG with base = 2?Thanks,Create
 
K

KJ

create said:
Hello,
there are two functions for logarithms in PACKAGE MATH_REAL:

function LOG (X : real ) return real;
-- returns natural logarithm of X; X > 0

function LOG (BASE: positive; X : real) return real;
-- returns logarithm base BASE of X; X

Here are the log functions prototypes from math_real....note, 'base' is not
a positive, it's real.
function log (x : in real ) return real;
function log2 (x : in real ) return real;
function log10 (x : in real ) return real;
function log (x: in real; base: in real) return real;
In my project i used first:constant CONST_LOG_NUMBER_SAMPLES : Natural :=
Natural(ceil(LOG(realCONST_NUMBER_SAMPLES))));
and it is correct.But I can not make second version:constant
CONST_LOG_NUMBER_SAMPLES : Natural :=
Natural(ceil(LOG(2,real(CONST_NUMBER_SAMPLES))));ORconstant
CONST_LOG_NUMBER_SAMPLES : Natural :=
Natural(ceil(LOG(real(2),real(CONST_NUMBER_SAMPLES))));How should I write
LOG with base = 2?Thanks,Create

Note that '2.0' is used as the base, not '2'.
constant CONST_LOG_NUMBER_SAMPLES : Natural :=
Natural(ceil(LOG(2.0,real(CONST_NUMBER_SAMPLES))));

Alternatively you could use the log2 function (see above).

KJ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top