## Recommended Posts

Submitted by mhdshaheed on Thu, 09/29/2011 - 16:16

Hi I am not understanding what is the meaning of min value seen and max value seen in constant fixed point block. When I enter a value such as 5.62. The output of this block is shown as 5.61897 instead of 5.62 and the number 5.62 is within the range of the block. Why is it showing a closest number instead of exact number?

##### Share on other sites

Submitted by Anders89 on Fri, 09/30/2011 - 02:06.

VisSim is giving you the effective value that you are representing given your choice of fractional bits and word size. For instance if you had an fx15.16 scale, this means you have 15 integer bits and 1 fractional bit. One fractional bit gives you 1/(2^1) or .5 as a smallest fractional value that you can count by. So numbers would go: 0 .5 1 1.5 2 2.5 .... With this scaling your 5.62 becomes 5.5.
If you used fx14.16 you would have 2 fractional bits and can count by 1/2^2 or .25 . In this case counting goes 0 .25 .5 .75 1 1.25 1.5 1.75 ... so 5.5 is still the closest you can come to 5.62. Note that 5.5 can be represented exactly in both scalings.

I don't know what scaling you used for your 5.62, but given your scaling VisSim is telling you that the closest value to 5.62 is 5.61897 .
Fundamentally, the reason for the difference is that we humans use decimal numbers since we have ten fingers. Computers use binary and so must approximate a fractional decimal value if it is not an inverse power of two. The more fractional binary bits you allocate, the closer you come to the decimal fraction. Of course you lose bits on the magnitude side. For constants, you typically want just enough magnitude bits to hold the integer part and use the rest for fractional values. The exception to this is when you are adding numbers: then you should choose the same scaling as the sum or else the constant will be shifted to agree with the sum scaling since all sum inputs must have the same scaling when the addition operation occurs.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.