|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
[c] calculating logs using a variable base number?
is there a math function in c to calculate a log using a variable base number?
i can see log2 and log which is base 10, but what happens if you want other than base 10 or 2? edit: oh, i've just found out log is not base 10. it calculates the natural logarithm of the given number (which uses e right?). log10 is the base10 version of log that uses base 10 Last edited by balance : April 25th, 2003 at 11:54 AM. |
|
#2
|
|||
|
|||
|
Code:
blog(n)=clog(n) / clog(b) For any c>0 (not sure about the exact bounds for c). i.e. you can use either log10() or log() for the both ![]()
__________________
-- Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more. |
|
#3
|
|||
|
|||
|
you confused me for a second there with your blogs'n'clogs (yes i did man blog and man clog
) , but i see what you mean now. got it. thanks. |
|
#4
|
|||
|
|||
![]() |
|
#5
|
|||
|
|||
|
they really should have taught you proper log functions in school.
lets say i have 5^x and it equals 25 (5^2 = 25). we right that as log5 25, correct? to calculate that, use the log of the big number / log of small number. you put it into your calculator like this: log(25) / log(5) if your calculator works properly, it will tell you the answer is 2 ![]() just remember ----> big number over little number (big as in how big you write it, not the value)
__________________
PHP is fun
|
|
#6
|
|||
|
|||
|
woops sorry. i guess the page didn't update because i thought it didn't post lol.
|
|
#7
|
|||
|
|||
|
i don't deny there's a few holes in my maths knowledge
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > [c] calculating logs using a variable base number? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|