Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
logarithm to the base of 2 (binary logarithm), base 10 and base n
#1
As I see, QB64 only knows the logarithm function LOG() to the base e.
The following small program calculates the binary logarithm ( logarithm to the base of 2) and the logarithms to the base 10 and n

Code: (Select All)

DIM AS _FLOAT a, n
a = 22
PRINT log2##(a)
PRINT logn##(22, 2)
PRINT logn##(22, 10)
PRINT log10##(22)

'Function log2: logarithm to the base of 2 (binary logarithm)
FUNCTION log2## (a)
    log2## = (LOG(a) / LOG(2))
END FUNCTION

'Function log10: logarithm of a to the base of n
FUNCTION log10## (a)
    log10## = (log2##(a) / log2##(10))
END FUNCTION

'Function logn: logarithm of a to the base of n
FUNCTION logn## (a, n)
    logn## = (log2##(a) / log2(n))
END FUNCTION

LOG10 is often called LG and
LOG is often LN (for natural logarithm).

Could these functions be implemented as standard QB64PE functions: _LOG2(), _LOG10(), LOGn(,)?
Reply


Messages In This Thread
logarithm to the base of 2 (binary logarithm), base 10 and base n - by BSpinoza - 10-02-2023, 12:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  I have a friend at IBM who is non-binary... Pete 8 1,414 01-04-2025, 02:19 AM
Last Post: SMcNeill
  Mix mode input of a binary open file Question! doppler 5 1,513 11-28-2024, 03:06 PM
Last Post: Petr

Forum Jump:


Users browsing this thread: 1 Guest(s)