LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-12-2005, 10:30 AM   #1
max_rsr
LQ Newbie
 
Registered: Mar 2005
Posts: 20

Rep: Reputation: 0
using expr to prinbt floating point result.


Please help me with the following problem

How can i use expr to print a floating point value

for example 14 /3 would result in 4 not 4.67
How can I achieve the floating point value?

Please help me with the following Shell script

the scripts seems to ask for a binary operator ..

# mgrep -- search for a file for 3 words in a line
# usage -- mgrep FILENAME word1 word2 word3.
...
Linux - General max_rsr 1 19 Today
02:05 PM

Displaying Topics 1 to 1 of 1
please Help.
 
Old 03-14-2005, 01:43 AM   #2
enemorales
Member
 
Registered: Jul 2004
Location: Santiago, Chile
Distribution: Ubuntu
Posts: 410

Rep: Reputation: 31
From

http://linuxreviews.org/beginner/abs.../en/c2850.html

Quote:
Bash does not understand floating point arithmetic. It treats numbers containing a decimal point as strings.

a=1.5

let "b = $a + 1.3" # Error.
# t2.sh: let: b = 1.5 + 1.3: syntax error in expression (error token is ".5 + 1.3")

echo "b = $b" # b=1

Use bc in scripts that that need floating point calculations or math library functions.
Hope this helps...
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Floating Point in kernel 2.4.28 lucs Slackware 1 10-19-2005 08:33 AM
Floating point exception hemk76 Linux - Software 1 05-06-2005 11:49 PM
how to use expr to print floating point values max_rsr Linux - Newbie 1 03-12-2005 10:00 PM
floating point multiplication irfanhab Programming 0 12-23-2004 10:13 PM
managing floating point vince_2x Linux - General 2 09-21-2004 09:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:56 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