Jump to content
Sign in to follow this  
VisSim Forum Archives

Fixed-point scaling issue?

Recommended Posts

Submitted by pete on Mon, 10/21/2013 - 21:23.

Hi Duco, The problem is the fx30.32 '*' (multiply) in the middle. fx30.32 means that you have 30 integer bits and 2 fractional bits in 32 bit word. 1 fractional bit lets you represent multiples of 1/2, 2 fractional bits lets you represent multiples of 1/4, 3 fractional bits gives you multiples of 1/8, and so on. You are feeding the multiply with .25 and .5, the result of which is .125 (or 1/8). You need 3 fractional bits to represent 1/8, but you only allocated 2, so the result is truncated to 0. If you know your largest result will be significantly less than 500 million, then you can move some integer bits to the fractional side and postpone the truncation. Generally you want enough integer bits to handle the largest input value you will see, but no more, as it steals precision away from fractional side.

We could add a warning when results are truncated to zero due to insufficient fractional bits.

Pete

Share this post


Link to post
Share on other sites

Join the conversation

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

Guest
You are posting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...