![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to compare big real numbers | padarthy | Shell Programming and Scripting | 4 | 10-02-2007 02:23 AM |
| How to Compare Floating point / real numbers | padarthy | Shell Programming and Scripting | 13 | 09-24-2007 05:03 PM |
| Compare integer value with decimal | MARY76 | Shell Programming and Scripting | 3 | 07-25-2007 06:47 AM |
| Devision of Decimal Numbers? | Vozx | Shell Programming and Scripting | 4 | 12-07-2005 03:26 AM |
| add numbers with decimal place in UNIX | tads98 | Shell Programming and Scripting | 4 | 07-21-2005 02:17 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
compare decimal numbers
Hi anyone,
i need to compare two decimal numbers i thought that it could be do it with if but... So, i'm writing in csh and i really apreciate if anyone can help me if ( $ppl_kn <= $ppl_wb ) then echo "############# KNdiscount model has the lowest perplexity" set ppl_LM_choosed = $ppl_LM_kn set LM_choosed = $LM_kn else echo "############# WBdiscount model has the lowest perplexity" set ppl_LM_choosed = $ppl_LM_wb set LM_choosed = $LM_wb endif Many thanks |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
That should be fine....
Code:
#!/usr/bin/csh -f set ppl_kn = 7 set ppl_wb = 6 if ( $ppl_kn <= $ppl_wb ) then echo "KNdiscount model has lowest perplexity" else echo "WBdiscount model has lowest perplexity" endif Also; people are going to yell "Don't use csh for scripting", for good reason too... Cheers ZB |
|
#3
|
||||
|
||||
|
Thanks by your quick reply.
however does not work if i make set ppl_kn = 7.1 set ppl_wb = 6.8 or set ppl_kn = 7,1 set ppl_wb = 6,8 The numbers i need to compare are not integers. Thanks anyway. |
|
#5
|
||||
|
||||
|
Use perl...
Code:
#!/usr/bin/perl
my $ppl_kn = 1.4;
my $ppl_wb = 1.2;
if ( $ppl_kn <= $ppl_wb ) {
printf "KNdiscount model has lowest perplexity\n";
} else {
printf "WBdiscount model has lowest perplexity\n";
}
ZB |
|
#6
|
|||
|
|||
|
Code:
ruby -e 'puts ($*.first.to_f <= $*.last.to_f) ? 1 : 0' 3.14 9 1 |
|||
| Google The UNIX and Linux Forums |