LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 08-23-2011, 03:33 AM   #1
olivia dunham
LQ Newbie
 
Registered: Aug 2011
Posts: 1

Rep: Reputation: Disabled
how to compare float number in shell program


I wanna know how to compare a float number with a int /float number in the shell program
 
Old 08-23-2011, 03:39 AM   #2
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 651

Rep: Reputation: 269Reputation: 269Reputation: 269
As far as I know, shell itself can't work with floats. you have to use a program like bc

example:
Code:
$ echo '1.5>1.2' | bc
1
$ echo '1.2>1.5' | bc
0
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How can I compare floating number in a shell script? abefroman Programming 29 09-10-2012 11:29 AM
how to program in shell to get a part of a file by line number George2 Linux - General 2 11-19-2006 02:41 AM
Simple C program - error with float J_K9 Programming 2 10-24-2005 11:36 AM
assigning a large float number in E notation edM Programming 3 05-09-2005 12:51 PM
C++ format float number output keefaz Programming 3 06-06-2004 02:16 PM


All times are GMT -5. The time now is 03:35 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration