Subject: | |
From: | |
Reply To: | |
Date: | Wed, 12 Mar 2003 22:31:45 EST |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
Paul asks:
> Can anyone enlighten me on what the following 'defined' function in BBXL is
> doing?
>
> DEF REAL FNL(SHORT INTEGER I1,I2)=I2+65536*(I1-(0 MIN SGN(I2)))
>
> I know that it tries to handle two 16 bit integers as a 32 bit integer that
> it assigns to a "Real" variable, but I' having difficulty with the "(0 MIN
> SGN(I2))" part.
Having never used Business BASIC, I can obviously claim no expertise, but if
BBXL is like other languages, the SGN part would return either a -1, 0 or 1,
depending on the sign of the variable I2. That value would then perhaps be
compared to 0, with the MIN of two returned, either a 0 or -1.
All of that would make sense if a 16-bit two's complement number was
attempting to be returned, based on the presence of the 65536 (where -1 in
16-bit two's complement equals 65535 in a 16-bit "raw" logical number, and
where 0 equals 0 and +1 equals +1 in the same arithmetic). Only if I2 were
negative, do you have to subtract one from the result for any number greater
than 32767 in order to make it a properly formatted 16-bit two's complement
("integer") number.
Wirt Atmar
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|
|
|