![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Floating point error in C | Hara | High Level Programming | 2 | 06-18-2008 06:43 AM |
| how to compare big real numbers | padarthy | Shell Programming and Scripting | 4 | 10-02-2007 06:23 AM |
| floating point problem | vijlak | High Level Programming | 4 | 03-08-2007 04:18 AM |
| floating point addition | ravi raj kumar | Shell Programming and Scripting | 8 | 12-22-2006 02:47 AM |
| problem with floating point numbers in awk | kanagias | Shell Programming and Scripting | 7 | 06-24-2005 04:14 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to Compare Floating point / real numbers
Hai,
Can you please guide me, to compare the floating point numbers. Eg. If [ $value1 > $value2 ] then echo "value1 is grater " fi This code is not working properly when i excuted with floating values or real numbers |
|
||||
|
HI,
I hope you can do it by awk. For me it is working fine ---------------------------------------------------------------------- # x=3.1; y=3.2; echo "$x $y" | awk '{if ($1 > $2) print $1; else print $2}' 3.2 ----------------------------------------------------------------------- I'm sure you can adapt it to your script ~~~Sanjay~~~ |
|
||||
|
Hi Virmin,
After excuting your code. i am getting a syntax error . echo "Enter value1" read value1 echo "Enter value2" read value2 Result=`echo "$Value1 > $Value2" | bc ` if [ $Result -eq 1 ] then echo "$value1 is greater" fi Error: ----- syntax error on line 1, teletype |
|
||||
|
Quote:
and you have to make sure $Value1 and $Value2 are legal numbers before you use them, or bc will fail. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|