Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 08-23-2011, 04: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, 04:39 AM   #2
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 852

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

$ echo '1.5>1.2' | bc
$ echo '1.2>1.5' | bc


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 34 10-12-2016 09:09 AM
how to program in shell to get a part of a file by line number George2 Linux - General 2 11-19-2006 03:41 AM
Simple C program - error with float J_K9 Programming 2 10-24-2005 12:36 PM
assigning a large float number in E notation edM Programming 3 05-09-2005 01:51 PM
C++ format float number output keefaz Programming 3 06-06-2004 03:16 PM > Forums > Linux Forums > Linux - Newbie

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

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