Longint
REMark + ------------------------------------------------------------------------ +
REMark |< Int% >|
REMark + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
REMark | Convert internal representation of an integer to a number |
REMark | |
REMark | Note: Range is between -32768 and + 32767 |
REMark | Note: n$ must be exactly 2 characters long! No checks! |
REMark + ------------------------------------------------------------------------ +
REMark | V0.01, pjw, 2021 Oct 04 |
REMark + ------------------------------------------------------------------------ +
:
DEFine FuNction Int%(n$)
LOCal t
t = CODE(n$(1)) * 256 + CODE(n$(2))
IF t > 32767: RETurn t - 65536
RETurn t
END DEFine Int%
:
:
REMark + ------------------------------------------------------------------------ +
REMark |< LongInt >|
REMark + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
REMark | Convert internal representation of a positive! long integer to a number |
REMark | |
REMark | Note: n$ must be exactly 4 characters long! No checks! |
REMark + ------------------------------------------------------------------------ +
REMark | V0.01, pjw, 2021 Oct 04 |
REMark + ------------------------------------------------------------------------ +
:
DEFine FuNction LongInt(n$)
RETurn Int%(n$(1 TO 2)) * 65536 + Int%(n$(3 TO 4))
END DEFine LongInt
:
:
REMark + ------------------------------------------------------------------------ +
REMark |< LongIntN >|
REMark + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +
REMark | Convert internal representation of any long integer to a number |
REMark | |
REMark | This routine is somewhat slower, but works with negative numbers too |
REMark | |
REMark | Note: n$ must be exactly 4 characters long! No checks! |
REMark + ------------------------------------------------------------------------ +
REMark | V0.02, pjw, 2024 Jul 31 |
REMark + ------------------------------------------------------------------------ +
:
DEFine FuNction LongIntN(n$)
LOCal i%, t
t = CODE(n$(1))
FOR i% = 2 TO 4: t = t * 256 + CODE(n$(i%))
IF t = 2 ^ 32: RETurn -1: REMark Rounding "error"?
IF t > $7FFFFFFF: RETurn t - 2 ^ 32
RETurn t
END DEFine LongIntN
:
:
Generated with sb2htm on 2024 Sep 25
©pjwitte 2oo1 - 2o22
QL Software
