Colr Attrbt (and 15)

 BBS: Inland Empire Archive
Date: 07-28-92 (21:58)             Number: 135
From: RICK PEDLEY                  Refer#: NONE
  To: BRYAN HOOVER                  Recvd: NO  
Subj: Colr Attrbt (and 15)           Conf: (2) Quik_Bas
 On 07-28-92 Bryan Hoover wrote to All...

 BH> Can anyone explain how works the formula, ForColr% = Atribute% AND 15
 BH> ?

 BH> What's happening with the AND operator and the number 15?

The attribute value is calculated by multiplying the background color
by 16 and adding the foreground color.  So to get the foreground
color by ANDing the attribute with 15:

Fg = 11
Bg = 1        'Attr = Bg * 16 + Fg
Attr = 27     'in binary is    00011011
              'AND with 15     00001111
                               --------
                               00001011 (which equals 11 decimal)
      0|1
     -----
   0 |0|0|
     --+--
   1 |0|1|
     -----
 AND truth table


... OFFLINE 1.40

--- Maximus 2.01wb
 * Origin: The BULLpen BBS * Intel 14.4EX (613)549-5168 (1:249/140)
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