Help! Unsigned #'s

 BBS: Inland Empire Archive
Date: 11-25-92 (02:28)             Number: 342
From: MIKE KERR                    Refer#: NONE
  To: TOM HAMMOND                   Recvd: NO  
Subj: Help!  Unsigned #'s            Conf: (2) Quik_Bas
TH>Now I'm REALLY confused!  Would anyone care to lend a helping hand and
TH>try to further my education... also head me in the proper direction.
TH>I'd always heard about unsigned numbers, but this is my first encounter
TH>with them...  I was so proud of myself that I'd managed to figure out
TH>all the other data types with no outside help and now I've spent four
TH>(fruitless) nights on this darn thing with nothing more than frustration
TH>to show for it.  If I had any hair left, I'd probably be pulling it out,
TH>but it's way too late for that.

Tom, when dates and things are stored as two bytes, especially integers,
and you want to read them in as UNSIGNED, this is how you calculate the
value of that integer:

I program in QuickBASIC, and the limitations on that are that integers
have only a max of 32767.  Integers from 0-65535 are represented in QB
as -32768 to 32767.  Therefore, you would need to use a LONG integer to
calculate it:

DIM days AS LONG

a$ = left$(word$,1)
b$ = right$(word$,1)

days = 256 * ASC(a$) + ASC(b$)


Or, another way you could do it, to save yourself two bytes, would be to
adopt the standard in computer date calcluation, which I believe is
01-01-1980.  It'll take at least until halfway through the next century
to access all possible values of a QB integer, and you can use a signed
integer in any other language for the same result.  I BELIEVE this takes
less time to calculate (signed) than it does with an unsigned integer,
but then, I'm not all that familiar with access times.

Hope this helps.

Mike
--- GEcho 1.00
 * Origin: Genesis BBS (416)878-5203 V.32b/V.42b Milton,Ont.CAN  (1:259/310)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET