Fractional Signed 2's complement representation

Discussion in 'VHDL' started by knight, Sep 16, 2008.

  1. knight

    knight Guest

    Hi


    What is the decimal representation of 1.111 1111 (signed 2's
    complement number) ..?
    I got it to be -0.0078125 but one site is telling that it is
    -0.00390625

    Which is correct..?
     
    knight, Sep 16, 2008
    #1
    1. Advertising

  2. knight

    Guest

    Hi,

    it is -0.0078125:

    1.111 1111 = -2 + 1 + 0.5 + 0.25 + 0.125 + 0.0625 + 0.03125 + 0.015625
    + 0.0078125

    TP
     
    , Sep 16, 2008
    #2
    1. Advertising

  3. knight

    Steff

    Joined:
    Sep 8, 2008
    Messages:
    11
    Hy,

    I agree with tarmopalm.

    I would also say that your number represents -0.0078125(dec).

    Short explanation:

    Your number is 1.111 1111(bin).
    Your scaling_factor then is (1/(2^scale_bitwidth)) (dec) = 0000 0001(bin).
    Your scaling_bitwidth is 7 because your point is on bit position 7 (or you have 7 ones behind your point).

    That means:


    0111 1111(bin) = 127(dec) * scaling_factor = +0.9921875
    .
    .
    .
    0000 0001(bin) = +1(dec) * scaling_factor = +0.0078125
    0000 0000(bin) = 0(dec) * scaling_factor = 0.0
    1111 1111(bin) = -1(dec) * scaling_factor = -0.0078125 <= your number
    .
    .
    .
    1000 0000(bin) = -128(dec) * scaling_factor = -1.0

    Hope it is clear for you?

    Steff
     
    Steff, Sep 16, 2008
    #3
  4. knight

    knight Guest

    knight, Sep 17, 2008
    #4
  5. knight

    Niv (KP) Guest

    On 17 Sep, 04:51, knight <> wrote:
    > On Sep 16, 5:09 pm, wrote:
    >
    > > Hi,

    >
    > > it is -0.0078125:

    >
    > > 1.111 1111 = -2 + 1 + 0.5 + 0.25 + 0.125 + 0.0625 + 0.03125 + 0.015625
    > > + 0.0078125

    >
    > > TP

    >
    > Hi
    > thanks for the clarification
    > Ive found it in this sitehttp://www.swarthmore.edu/NatSci/echeeve1/Ref/BinaryMath/NumSys.html#...
    > under heading Signed binary fractions
    >
    > Thank you


    No, not quite right:
    -2 + 1 + 0.5 + 0.25 + 0.125 + 0.0625 + 0.03125 + 0.015625 + 0.0078125
    is 9 terms.

    Should it not be -1 for the 1 before the decimal point and then :
    0.5 + 0.25 + 0.125 + 0.0625 + 0.03125 + 0.015625 + 0.0078125 added to
    the -1

    Just my opinion of course.
     
    Niv (KP), Sep 17, 2008
    #5
  6. knight

    knight Guest

    On Sep 17, 4:01 pm, "Niv (KP)" <> wrote:

    > No, not quite right:
    > -2 + 1 + 0.5 + 0.25 + 0.125 + 0.0625 + 0.03125 + 0.015625 + 0.0078125
    > is 9 terms.
    >
    > Should it not be -1 for the 1 before the decimal point and then :
    > 0.5 + 0.25 + 0.125 + 0.0625 + 0.03125 + 0.015625 + 0.0078125 added to
    > the -1
    >
    > Just my opinion of course.



    aren't the both same.....?
     
    knight, Sep 17, 2008
    #6
  7. knight

    Muzaffer Kal Guest

    On Tue, 16 Sep 2008 04:37:45 -0700 (PDT), knight <>
    wrote:

    >Hi
    >
    >
    >What is the decimal representation of 1.111 1111 (signed 2's
    >complement number) ..?
    >I got it to be -0.0078125 but one site is telling that it is
    >-0.00390625
    >
    >Which is correct..?


    Another way to look at fractional two's complement signed numbers is
    to use scaling. To go to fractional from integer in 1.7 format (as in
    your example above) you need to scale the integers by 1/128 because
    every left step you take with the binary point divides the number by
    2 so x.7 means 1/128.
    So 1111 1111 == -1 then 1.111 1111 == (-1) * 1/128 == -0.0078125.
     
    Muzaffer Kal, Sep 20, 2008
    #7
  8. knight

    Firoz Pervez

    Joined:
    Feb 18, 2009
    Messages:
    2
    2's complement of a fractional number

    Decimal equivalent of (1.1111111)2 is (1.9921875)10
    If N is a number of base r
    And n is the no. of digit of integer part of the number N,
    Then ,
    2’s complement of N is,

    r¬¬n-N
    =(21)10-(1.1111111)2
    =(21)10-(1.9921875)10
    =(0.0078125)10 (Ans.)
    You can also find 2’s complement this way:
    1’s complement of (1.1111111)2 is(0.0000000)2
    DON’T NEGLECT ANY 0.
    Now, add 1 to the Least Significant Digit i.e.
    add r – m to the 1’s complement (where m is the no. of digit of fractional part) :
    0.0000000
    + 0.0000001
    =0.0000001
    This (0.0000001)2 is the 2’s complement of (1.1111111)2 in binary form.
    The decimal equivalent of this number (0.0000001)2 is (0.0078125)10 (Ans.)
     
    Firoz Pervez, Feb 18, 2009
    #8
  9. knight

    Firoz Pervez

    Joined:
    Feb 18, 2009
    Messages:
    2
    2's complement of a Fractional numer

    Decimal equivalent of (1.1111111)2 is (1.9921875)10
    If N is a number of base r
    And n is the no. of digit of integer part of the number N,
    Then ,
    2’s complement of N is,

    r^n -N
    =(21)10-(1.1111111)2
    =(21)10-(1.9921875)10
    =(0.0078125)10 (Ans.)
    You can also find 2’s complement this way:
    1’s complement of (1.1111111)2 is(0.0000000)2
    DON’T NEGLECT ANY 0.
    Now, add 1 to the Least Significant Digit i.e.
    add r^ (– m) to the 1’s complement (where m is the no. of digit of fractional part) :
    0.0000000
    + 0.0000001
    =0.0000001
    This (0.0000001)2 is the 2’s complement of (1.1111111)2 in binary form.
    The decimal equivalent of this number (0.0000001)2 is (0.0078125)10 (Ans.)
     
    Firoz Pervez, Feb 18, 2009
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Martin Maurer
    Replies:
    3
    Views:
    4,945
    Peter
    Apr 19, 2006
  2. Mantorok Redgormor

    sign magnitude, ones complement, two's complement

    Mantorok Redgormor, Oct 5, 2003, in forum: C Programming
    Replies:
    8
    Views:
    8,640
    Glen Herrmannsfeldt
    Oct 8, 2003
  3. sarathy

    1's complement and 2's complement

    sarathy, Aug 1, 2006, in forum: C Programming
    Replies:
    20
    Views:
    2,217
    Bo Persson
    Aug 2, 2006
  4. sarathy
    Replies:
    22
    Views:
    2,371
    Bo Persson
    Aug 2, 2006
  5. Roberto Waltman

    2's complement vs. 1's complement vs. ...

    Roberto Waltman, Jun 9, 2011, in forum: C Programming
    Replies:
    4
    Views:
    1,368
    Michael Press
    Jun 14, 2011
Loading...

Share This Page