The result for negative numbers is quite understandable if one assumes that
the number is always rounded "down" by the INT operation. In languages
such as C whether one rounds towards 0 or rounds downwards is often an
"implementation defined" feature - i.e. there is no official standard.
Dave
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, June 19, 2001 10:05 AM
Subject: RE: [ql-users] NEXT in FOR-loop
> Morning all,
>
> I managed to do a bit of experimenting on the INT(x) problem last night.
>
> Counting down gave the following results:
> 3.03 3
> 3.02 3
> 3.01 3 The correct result for 3 this time is because the
> 3 3 internal value printed as 3 will be slightly higher
> 2.99 2 and rounded down.
> 2.98 2
> 2.97 2
> 2.96 2
> 2.95 2
>
> The results for negative numbers are strange and I can't attribute this
> to
> rounding. I wonder if the original QL would have given the same
> results using it's software floating point routines instead of the
> 68040's FPU.
>
> -2.95 -3 -3.03 -4
> -2.96 -3 -3.02 -4
> -2.97 -3 -3.01 -4
> -2.98 -3 -3 -3
> -2.99 -3 -2.99 -3
> -3 -3 -2.98 -3
> -3.01 -4 -2.97 -3
> -3.02 -4 -2.96 -3
> -3.03 -4 -2.95 -3
>
> I was hoping to try an equivalent test in C and Assembler using the
> 68040 FINT and FINTRZ instructions but didn't have time.
>
> Ian.
>
> > -----Original Message-----
> > From: zeljko.nastasic
> > Sent: 18 June 2001 16:43
> > To: ql-users
> > Cc: zeljko.nastasic
> > Subject: RE: [ql-users] NEXT in FOR-loop
> >
> >
> > On 6/18/01 at 3:44 PM Claude Mourier 00 wrote:
> >
> > >Thank's a lot for all the answers. But this is quite
> > annoying : especially
> > >because behavior is not the same for PRINT and INT. Better if PRINT
> > returns
> > >something like 2.99999 (in fact SMS loves exponential form I
> > personaly
> > >hate). I'm not sure but I think even FDEC$(n, 9, 8) returns 3.00000.
> > >
> > >Claude
> >
> > No, it's Print. Eventually, you have to print it and that's where the
> > rounding happens. FDEC$ does an implicit print, so again you
> > cannot escape
> > rounding. The only way would be to get the actual float
> > representation from
> > memory as 6 bytes and convert them 'manually'.
> >
> > Nastan
> >
> >
>
>
> Visit our website at http://www.ubswarburg.com
>
> This message contains confidential information and is intended only
> for the individual named. If you are not the named addressee you
> should not disseminate, distribute or copy this e-mail. Please
> notify the sender immediately by e-mail if you have received this
> e-mail by mistake and delete this e-mail from your system.
>
> E-mail transmission cannot be guaranteed to be secure or error-free
> as information could be intercepted, corrupted, lost, destroyed,
> arrive late or incomplete, or contain viruses. The sender therefore
> does not accept liability for any errors or omissions in the contents
> of this message which arise as a result of e-mail transmission. If
> verification is required please request a hard-copy version. This
> message is provided for informational purposes and should not be
> construed as a solicitation or offer to buy or sell any securities or
> related financial instruments.
>
>