Laurence W Reeves writes:

>P Witte wrote:
>> Marcel Kilgus writes:
>>> Wolfgang Lenerz wrote:
>>>>  On 15 Dec 2006 at 15:57, George Gwilt wrote:
>>>>> On an ordinary QL I can type
>>>>>
>>>>> f%=-32768/1
>>>>>
>>>>> and find that f% now contains -32768.
>>>>>
>>>>>
>>>> Well that must be a nice bug.
>>>>
>>>> unless I'm mistaken, 32768/1 = 32768
>>>>
>>>> and 32768 just doesn't fit in an integer.
>>>>
>>> Yes, but -32768 does. Notice the minus ;-)
>>>
>>
>> Ah, but  the rub is that "f%=-32768/1" is within range and shouldnt
>> overflow.
> Hi all..
>
> This strikes me as a *very* serious bug.
>
<>
> Yet other variants of writing the code could look like 
> "f%=-+327.68E2/+100E-2".
> Offhand, I'm not sure what happens with these. I'm fairly sure Minerva 
> tends
> lose the cruddy bits during (re-)tokenisation... it's like that.

SMSQ/E doesnt like f% = -327.68E2 / +100E-2 it overflowes as for the 
original example, but f% = -3.2768e4 is fine - until you try to divide it by 
1. Weird.

> Bugs aside, the question I'd ask is why someone is using "/" instead of 
> "DIV"
> when they are apparent intend to do integer calculations. (A challenge... 
> find
> a genuine *practical* reason for "/" versus "DIV", other than saving 
> typing.)

f% = -32768 DIV 1 works as advertised ;o)

There is a reason you might want to use / rather than DIV and that is 
rounding versus truncating:

i% = 7 DIV 2  gives 3 while
i% = 7 / 2  gives 4

Does that pass the challenge?

Per 
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm

Reply via email to