Ah, now explained like that with all the maths makes it much clearer
(yes, really it does :) so when we want to find out the exponent of the 
number whose common logarithm is the argument to INT() then we have a 
useful function that does just that.

> This is one case where the manual gets it wrong; it states: "INT will 
return the
> integer part of the specified floating point expression."

I still think an INT function that does just that, i.e. round towards 
zero, would be more useful more often.  However, once you know that the 
behaviour has a logical explanation and is predictable, it is easier to 
accept the limitations and work around them.

Ian.

> -----Original Message-----
> From: cigmorfil 
> Sent: 19 June 2001 21:20
> To: ql-users
> Cc: cigmorfil
> Subject: Re: [ql-users] NEXT in FOR-loop
> 
> 
> > Hmmm - the odd behaviour with negative numbers is not 
> unique to SBASIC.
> >   I've just tried it with QBASIC in NT and it does exactly the same.
> > I'd be interested to read the ISO or ANSI standard on this for the
> > justification.  Curiously, the 68040 provides two instructions for
> > getting an integer from a float:  FINT allows user 
> specified rounding,
> > e.g. 'round-to-nearest', while FINTRZ always does 
> 'round-to-zero'.  I
> > still can't see the usefulness in having INT(-3.01)=-4 though.  Any
> > mathematicians care to comment?
> 
> When I first learnt BASIC (all those years ago, when you 
> could buy x, y
> and z, the bus fare home and still have change from a �50 pound note
> <grin>) INT was described as returning the largest integer not greater
> than its argument.  [GeeWizz-BASIC that came with PC's ('scuse the
> language) defined INT as "Returns the largest integer less 
> than or equal
> to x.  Examples INT(99.89) -> 99, INT(-12.11) -> -13.]
> 
> The only [vague] usefulness of this that I can think of (off hand) is
> when I learnt to use (base 10) log tables (23+ years ago, BC - Before
> Computers [well, ok, before micros were available] - when a pocket
> calculator, needing B6 size pockets, only did basic maths):
> 
>  1: convert the number to standard (scientific) format (y.yy x 10^n)
>  2: look up the log of y.yy (0.lll)
>  3: add the exponent n to give n.lll
> 
> eg: lg(202) = lg(2.02 x 10^2) = 0.305 + 2 = 2.305
> 
> INT(2.305) => 2 implies the exponent(/size?) of the original number is
> 2. 
> 
> However, if n is negative, the actual number will be -m.kkk.
> 
> eg: lg(0.00202) = lg(2.02 x 10^-3) = 0.305 + -3 = -2.695.
> 
> So, using INT(-2.695) = -3 implies that the exponent(/size?) of the
> original number is -3.
> 
> BTW, my (Classic) JM QL gives INT(-3.1) => -4.  This is one case where
> the manual gets it wrong; it states: "INT will return the integer part
> of the specified floating point expression."
> 
> Robert
> 
> 


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.

Reply via email to