Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Awk > compare numbers...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 8 Topic 2186 of 2234
Post > Topic >>

compare numbers behaves strange...

by di98mase <di98mase@[EMAIL PROTECTED] > Mar 12, 2008 at 06:40 AM

Hi

I have a file with numbers in it. My program reads the values and
compare them and depending on the value I increment a counter. what I
have seen is that the evaluation fails. This is an extract of my
numbers:

7
7
7
34
92
111
294
121
142

This is parts of my program that checks the value (ms) read from the
file and increments the counters

      if( ms == 18) t18++;
      if( ms == 19) t19++;
      if( ms >= 20 && ms < 30)
      {
         print ms;
         t20++;
      }
      if( ms >= 30 && ms < 40) t30++;
      if( ms >= 40 && ms < 50) t40++;
      if( ms >= 50 && ms < 60) t50++;
      if( ms >= 60 && ms < 70) t60++;

As you can see I dont have any numbers between 20 and 30 but I still
get an increment for the t20 counter. When I print the value it is
"294". Why do I have this behaviour?




 8 Posts in Topic:
compare numbers behaves strange...
di98mase <di98mase@[EM  2008-03-12 06:40:05 
Re: compare numbers behaves strange...
Ben <benoit.bardet@[EM  2008-03-12 07:05:40 
Re: compare numbers behaves strange...
Luuk <Luuk@[EMAIL PROT  2008-03-12 15:15:03 
Re: compare numbers behaves strange...
Janis <janis_papanagno  2008-03-12 07:28:05 
Re: compare numbers behaves strange...
di98mase <di98mase@[EM  2008-03-12 07:33:25 
Re: compare numbers behaves strange...
Luuk <Luuk@[EMAIL PROT  2008-03-12 15:51:02 
Re: compare numbers behaves strange...
di98mase <di98mase@[EM  2008-03-12 08:53:01 
Re: compare numbers behaves strange...
Janis <janis_papanagno  2008-03-12 08:58:15 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon May 12 0:35:22 CDT 2008.