LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-20-2010, 06:45 AM   #1
himu3118
Member
 
Registered: Mar 2010
Posts: 35

Rep: Reputation: 15
logarithm


can we find logarithm to base 10 instead of base 2 on shell script??

i can do it with bc..
like

'l(1000)/l(10)' | bc -l

Last edited by himu3118; 04-20-2010 at 06:49 AM.
 
Old 04-20-2010, 07:41 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Actually the function l in bc computes the natural logarithm. What you've done is simply a conversion of the logarithm base, using the formula in attachment (where in this case b is the natural number e and a is 10).
Attached Thumbnails
Click image for larger version

Name:	logbase.png
Views:	25
Size:	5.3 KB
ID:	3396  
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
calculate logarithm in bash script bluesmoke Programming 5 12-14-2008 01:41 AM
Stongest, most secure logarithm wwnexc Linux - Security 3 12-09-2005 11:01 PM
How to calculate integer binary logarithm in C? shy Programming 1 11-27-2004 07:43 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration