Results 1 to 2 of 2

Thread: Math with Bits

  1. #1
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,817
    Rep Power
    10

    Math with Bits

    [code=thinbasic]
    uses "console"

    dim a,b,c as long

    b = &H09700
    c = &H03FFF

    a = b and c
    PrintResults("--- AND operation: a = b and c", a, b, c)

    a = b or c
    PrintResults("--- OR operation: a = b or c", a, b, c)

    a = not b
    PrintResults("--- NOT operation: a = not b ", a, b, c)
    console_waitkey

    function PrintResults(Operation as string, a as long, b as long, c as long)
    console_writeline Operation
    console_writeline "b = " & BIN$(b, 32) & " " & hex$(b, 4)
    console_writeline "c = " & BIN$(c, 32) & " " & hex$(c, 4)
    console_writeline string$(40, "-")
    console_writeline "a = " & BIN$(a, 32) & " " & hex$(a, 4)
    console_writeline ""
    end function
    [/code]
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  2. #2
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,865
    Rep Power
    405

    Re: Math with Bits

    Thanks Eros nice example!!
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

Similar Threads

  1. Replies: 10
    Last Post: 21-03-2008, 10:54

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •