On  Mon, 18 Jun 2001 at 10:48:56, you wrote:
(ref: <H0000b5f10b5f2cd.0992857733.ln4p1327.ldn.swissbank.com@MHS>)

>Only guessing because I can't try this until I get home, but when n
>reaches the value 2.9999....  (the nearest it'll get to 3.00 because
>0.01 is not represented exactly internally [that would need an infinite
>number of bits]), then PRINT n  will round up to 3, whereas INT(n) will
>return the correct answer (2) which needs no rounding and therefore
>prints as 2.
>
>Try this:
>FOR n=2.953125 TO 3.03125 STEP 0.015625:PRINT n, INT(n)
>and see if you get any unexpected results.

Minerva:

2.953125        2
2.96875         2
2.984375        2
3               3
3.015625        3
3.01325         3

Minerva gives  3 ....  2 for the original prog also.

You are right.....
>> Claude Mourier 00 wrote:
>>
>> > As I see a question about FOR/NEXT loops, I have mine:
>> > the subsequent peice of code gives me an unexpected result
>> > FOR n = 2.95 to 3.05 STEP 0.01 : print n, INT(n)
>> > Why ?
>> >
>> > Claude
>> > (I am using QPC2v2.00 and SMSQ/e v2.98)
>> >
>> >
>>

-- 
           QBBS (QL fido BBS 2:257/67) +44(0)1442-828255
mailto:[EMAIL PROTECTED]     http://www.firshman.demon.co.uk
        Voice: +44(0)1442-828254      Fax: +44(0)1442-828255
      TF Services, 29 Longfield Road, TRING, Herts, HP23 4DG

Reply via email to