Results 1 to 3 of 3

Thread: Bit operands - why???

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Location
    Croatia,Zadar
    Posts
    7

    Angry Bit operands - why???

    Code:
    x=37 , console.write(not x) = -38
    Why?? If "not" operand is reversing bits from 0 to 1 and other way around how can result be -38?? 0001 should be 1110, or I'm so wrong?

  2. #2
    PowerPoster
    Join Date
    Jul 2002
    Location
    Dublin, Ireland
    Posts
    2,148

    Re: Bit operands - why???

    Negative numbers are represented using Twos complement

  3. #3
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Bit operands - why???

    It depends what data type you use. On the x86 platform, you can't store a 4-bit number; the smallest data type is a byte (8 bits).

    ~00000001 in a byte is 11111110, which in an unsigned byte is 254.

Posting Permissions

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



Click Here to Expand Forum to Full Width