Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] representation of negative fraction

Status
Not open for further replies.

dipin

Full Member level 4
Full Member level 4
Joined
Jul 16, 2014
Messages
223
Helped
14
Reputation
28
Reaction score
14
Trophy points
18
Visit site
Activity points
1,731
hi,
can i use 2's complement form to represent negative fraction.
did anyone plz tell me how negative fraction is represented in xilinx ip core. eg for -.25 binary:1110
-.375 binary:1101

can i use like this
thanks & regards
 

0.25 = 0000.0100
-0.25 = 1111.1011 + 0000.0001 = 1111.1100

0.375 = 0000.0110
-0.375 = 1111.1001 + 0000.0001 = 1111.1010
\

thanks for the replay
but problem is : when i store it into seperate registers as integer and fractional part it will become integer as -1 (orginally zero). and fraction

that is 1111.1000 it will become -1.5. so i thought of using 2's complement to fractional part also.i think in xilinx ip core they are using -ve(signed representation) to both binary and fraction . th at is main reason i asked this
did anyone plz tell me how negative fraction is represented in xilinx ip core.

thanks & regards
 

Im not quite sure I follow.

in 4.4 2s compliment notation:
1111.0000 = -1
1111.1000 = -0.5

Which IP core are you refering to? all arithmetic cores will use 2s compliment.
 

thanks for the replay
Which IP core are you refering to? all arithmetic cores will use 2s compliment.

any ip core of xilinx . i just checked the data sheet of IP Divider
Generator v3.0, i think(not sure) they are using 2'complement for both quotient and fraction

so -1.5 will become 1111.1100
1111.1000 = -0.5
in this case the problem is we need to output quotient and fraction seperately.
so it will become -1 and .5

honestly i didnt used any ipcore until now . so i dont know how they give output.
please help
thanks &regards
 
Last edited:

so -1.5 will become 1111.1100
Nobody else seems to notice that you keep saying -1.5 is equal to 1111.1100, I don't see how you get that value.

In 2's comp -1.5 = 1110.1000 = -2^3 + 2^2 + 2^1 + 2^-1 = -8 + 4 + 2 + .5 = -1.5
and 1111.1100 = -8 + 4 + 2 + 1 + .5 + .25 = -.25

So in the case of any Xilinx IP core, which performs 2's comp arithmetic (which is exactly the same as binary) the value -1.5 isn't 1111.1100 as you seem to think.

To produce the values using your non-standard format. You would have to take the 2's comp of the value 1110.1000 (-1.5).
e.g.
1110.1000 -1.5 (note value is '-' and save in a flag)
0001.0111 invert
0000.0001 add 1
0001.1000 +1.5
separate into integer and fractional...
0001 .1000 1 & .5
note flag from previously...
1110+0001 .1000 (2's comp of 1) & .5
1111 .1000 -1 & .5

dipin said:
in this case the problem is we need to output quotient and fraction seperately.
so it will become -1 and .5
I have no idea why you would want to do something like this. It doesn't make any sense to store the integer and fractional parts of a number separately. If you need the fractional part separately from the integer part at some point just perform the 2's comp conversion at that point and extract the fractional part.

Regards

- - - Updated - - -

After looking at some of your other posts...

There is no representation of a negative fraction without an integer portion as you have to have a '-1' to add positive fractional values to. I think the problem is you aren't thinking of the numbers as exponentially weighted sums, so negative fractions are really a weighted sum of fractions added to a negative unity value.

-0.5 in 1.4 2's comp = 1.1000 = -2^1 + 2^-1 = -1 + .5
and 0.5 in 1.4 2's comp = 0.1000 = 2^-1
 
  • Like
Reactions: dipin

    dipin

    Points: 2
    Helpful Answer Positive Rating
thanks for the replay ads-ee,

now i undestand my problem.
i have designed a divider which output quotient and fraction . i looked into the data sheet of xilinx divider ip core which is saying that
For signed mode with fractional remainder, the sign bit is present both in the quotient and the
fractional remainder. For example, for a five-bit dividend, divisor and fractional remainder we have:
-9/4 = 9/-4 = -(2 1/4)
This corresponds to:
10111/00100 or 01001/11100
Giving the result:
Quotient = 11110 (= -2)
Remainder = 11100 (= -1/4)

so according to this quotient: 11110 = -16+8+4+2=-2
and fraction : 11100= -1+.5+.25 =-.25
right

so -1.5 i can represent like quotient:1111
fraction:1100
is this right or wrong this is my confusion.

https://www.xilinx.com/support/documentation/ip_documentation/div_gen_ds530.pdf



thanks & regards
 
Last edited:

No, you are missunderstanding the documentation.

Quotient = result
remainder = value left over that cannot be fully divided. This could be an integer AND fraction, depending on the number of bits in the quotient and dividend

For example:

9/2 (using 1 as LSB) = quotient 4, remainder 1.

7.0 / 1.5 (using 0.25 as LSB) = quotient 4.5, remainder 0.25.

1.5*4 = 6 (rem 1)
+1.5*0.5 = 6.75 (rem 0.25)

1.5 * 0.25 = 0.375 (0.25/0.375 = 0 remainder 0.25).
 

No, you are missunderstanding the documentation.

Quotient = result
remainder = value left over that cannot be fully divided. This could be an integer AND fraction, depending on the number of bits in the quotient and dividend

For example:

9/2 (using 1 as LSB) = quotient 4, remainder 1.

7.0 / 1.5 (using 0.25 as LSB) = quotient 4.5, remainder 0.25.

1.5*4 = 6 (rem 1)
+1.5*0.5 = 6.75 (rem 0.25)

1.5 * 0.25 = 0.375 (0.25/0.375 = 0 remainder 0.25).
I am also talking about division result only
if i divide -6/4 according to doccumentation results are
quotient:11111 :: -1
fraction: 11000 ::-1+.5

and if i divide -5/10 gives quotient :00000
fraction: 11000 ::-1+.5
i am really sorry if i wrong.i am confused . in internet i did'nt found anything

regards
 

stop calling it a fraction - its a remainder. Secondly, your result isnt correct, because you have 0 fraction bits in your quotient

-6/4 = 11010/00100 (these Are all integer bits. With 0 fraction bits numerator and dividend you get 0 fraction bits in the result)

Qutient = 11111 (-1)
remainder = 11110 (-2)

now lets add some fraction bits to them

-6 = 11010.00
4 = 00100.00

quotient = -1.5 (11110.10)
remainder = 0
 

Tricky,

The IP document says it can output a fractional value or a remainder. The fractional value is preceded by a "sign" bit in 2's complement form so in the OP's case the output for -.5 would be 11000 (1.1000 = -1 +.5, for 5-bits).

Also the result of any division of a negative number produces a result that is represented as both the quotient and fractional value as negative numbers. e.g.
-1.5 (represented as separate quotient/fractional):

11111. (-1), 1.1000 (-.5)
which you add... -1+ -.5 = -1.5
or adding in 2's comp binary:
11111.0000
00001.1000
--------------
11110.1000 = -16 + 8 + 4 + 2 + .5 = -1.5

Regards
 
Last edited:
  • Like
Reactions: dipin

    dipin

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top